Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Jordi Boggiano:
PHP Versions Stats - 2016.1 Edition
Jun 07, 2016 @ 14:51:35

Jordi Boggiano has posted some updated statistics around the use of the Packagist site around PHP version requirements and the relation of package downloads to PHP versions.

Last year I posted stats about PHP versions, and the year before as well, both time in November. However this year I can't wait for November as I am curious to explore the PHP7 uptake!

A quick note on methodology, because all these stats are imperfect as they just sample some subset of the PHP user base. I look in the packagist.org logs of the last 28 days for Composer installs done by someone. Composer sends the PHP version it is running with in its User-Agent header, so I can use that to see which PHP versions people are using Composer with.

He compares the previous statistics against the ones gathered back in November 2015, both in numbers and graphs. He shows the stats for the PHP versions being used and for the PHP versions that are required. It's interesting to see that there's been a good uptick in supported versions including PHP 7.0+.

tagged: packagist statistics version composer usage requirement

Link: https://seld.be/notes/php-versions-stats-2016-1-edition

What Are Laravel Exceptions?
Apr 18, 2016 @ 12:25:35

In a new tutorial posted on the TutsPlus.com site they get into some detail about what exceptions are in Laravel-based applications, when to use them and how to make your own.

As a PHP developer, you may use exceptions, because they allow you to notice when something has gone wrong or the user has acted in an unusual way (such as division by zero). Without exceptions, your application would end up presenting unwanted errors and being much more difficult to debug. It is also important that you halt execution immediately and take another course of action.

Exceptions are really simple, and they will make your development progress easier. When you learn how to use exceptions, this will be a usual part of your development.

They start by explaining what exceptions are (in the strictest sense, a definition from Martin Fowler) and an example of how one is caught in PHP. They briefly talk about when to use exceptions and how they're implemented in Laravel. The post finishes with a look at creating your own exception types and where to place them in your application. They also make the suggestion of using the Assertion package to verify data and catch the AssertionFailedException if there's an issue.

tagged: laravel exception example tutorial overview usage

Link: http://code.tutsplus.com/tutorials/what-are-laravel-exceptions--cms-25816

Laravel Daily:
Holywar: when to use Laravel vs WordPress?
Feb 18, 2016 @ 11:09:15

On the Laravel Daily site there's an interesting article that shares some opinions on when to use Laravel and when to use WordPress as a base for your applications.

In PHP world there are two big groups of developers – those who work with Content Management Systems (WordPress, Drupal etc.) and those with frameworks (Laravel, Symfony etc.). And rarely people work with both worlds – cause their philosophy is fundamentally different.

But when you get a new project from a client – how to decide whether Laravel is the best choice? Or maybe simple WordPress would be enough and would save time/money? Sometimes it’s not that easy to decide. So here are my tips – questions you need to ask.

In the remainder of the article he suggests four questions to ask yourself to help make the decision one way or another:

  • Content or user actions?
  • Plugins or packages?
  • MVP or serious project?
  • Who will work on the project?

He elaborates on each point with a bit more context and criteria that could help answer the question in your case.

tagged: laravel wordpress usage questions evaluate decision

Link: http://laraveldaily.com/holywar-when-to-use-laravel-vs-wordpress/

Evert Pot:
Strict typing in PHP 7 - poll results
Jan 15, 2016 @ 11:19:54

Evert Pot has shared the results of a poll he recently set up on Twitter asking PHP developers if they planned to make use of the strict typing functionality in PHP 7 in their applications. Unsurprisingly, the majority voted that they will with a more undecided audience coming in second.

Type hinting comes in two flavors: strict and non-strict. This is the result of a long battle between two camps, a strict and non-strict camp, which in the end was resolved by this compromise.

Now by default PHP acts in non-strict mode, and if you'd like to opt-in to strict-mode, you'll need to start every PHP file with this statement. [...] So I was curious about everyone and whether you will be using strict mode or not. Results are in.

According to those that voted 46% were completely in favor of using the declare statement to enable strict typing in their PHP 7 code by default. The next group, the "undecided" were at 26% with "no way" and "what is that?" coming in farther down the list. He also mentions a package that's in the works from Justin Martin that would automatically add the declare statement to your code in the desired location(s). Additionally there's an extension in development from Joe Watkins that will do the same thing but making it a bit more automatic.

tagged: php7 strict type declare poll results usage composer package extension

Link: https://evertpot.com/strict-types-pollresults/

Jordi Boggiano:
PHP Versions Stats - 2015 Edition
Nov 23, 2015 @ 13:17:54

It's come to "that time of year" again and Jordi Boggiano has posted the latest update in his series of PHP usage statistics. In this summary he looks at the PHP versions installed based on the packagist.org logs for developers using Composer.

It's that time of the year again, where I figure it's time to update my yearly data on PHP version usage. Last year's post showed 5.5 as the main winner and 5.3 declining rapidly. Let's see what 2015 brought.

[...] A quick note on methodology, because all these stats are imperfect as they just sample some subset of the PHP user base. [...] Composer sends the PHP version it is running with in its User-Agent header, so I can use that to see which PHP versions people are using Composer with. Of course this data set is probably biased towards development machines and CI servers and as such it should also be taken with a grain of salt.

He first compares the statics for his 2015 searches against the 2014 stats and shows the differences in usage for PHP versions 5.3.3 up to 5.6.0. Fortunately, the results show a rise in the usage of PHP 5.5 and a decline in all others...but it's not too much of a difference (2-3% range). Pie graphs are also included to help visualize these differences. He also includes some statistics on what PHP versions are required by certain packages for the ones listed on Packagist with increases starting with 5.4 and the largest advance for 5.5.

tagged: usage statistics version comparison yearly packagist composer required

Link: http://seld.be/notes/php-versions-stats-2015-edition

Create a Custom API in Magento: Part Two
Jul 03, 2015 @ 10:54:02

NetTuts.com has posted the second part of their series showing how to create a custom API in Magento. In part one of the series they focused on creating a custom module that worked with the core APIs and system. In this new post they approach it from the other side and show how to use those APIs created in part one.

In this series, we're discussing custom APIs in Magento. In the first part, we created a full-fledged custom module to implement the custom API, in which we created the required files to plug in the custom APIs provided by our module. In this second and last part, we'll go through the back-­end section to demonstrate how to consume the APIs.

They start with a quick recap of the things created in the first part of the series and how to ensure it's set up correctly to be accessed as an API endpoint. Next they set up the user and role configurations that you'll need to access the new API through the administration panel. Finally, they show you how to use the API through a simple SoapClient request.

tagged: magento custom api series tutorial part2 usage

Link: http://code.tutsplus.com/tutorials/create-a-custom-api-in-magento-part-two--cms-23821

Peter Petermann:
A few thoughts about composer and how people use it
May 18, 2015 @ 10:17:43

In the latest post to Peter Petermann's site he shares a few thoughts about Composer and how people use it in the more modern PHP ecosystem.

Composer has changed the PHP ecosystem like now other tool introduced – almost everyone is using it today. Now, I have written about Composer before, and have always been a big proponent of using it. However, as i have spend some time with looking more closely on a few things, there is a few problems (some with Composer, some with how people (ab)use Composer) that I would like to write about.

He's broken the list up into six different point, each with a bit of explanation:

  • Composer gets slow and resource hungry
  • People are using composer as an installer
  • People use their own paths
  • People don’t adhere semver
  • People don’t tag their releases / don’t release
  • People release packages with dependencies to unstable versions

He ends the post by looking at each of these points and offering a brief one-liner way to help solve the issue (or at least minimize the problem).

tagged: composer opinion problem usage ecosystem package

Link: https://devedge.wordpress.com/2015/05/16/a-few-thoughts-about-composer-and-how-people-use-it/

Julien Pauli:
Zoom on PHP objects and classes
Mar 26, 2015 @ 12:50:49

Julien Pauli has a recent post to his site that "zooms in" on objects and classes with a look behind the scenes at how they're handled in the PHP source (at the C level) with plenty of code examples and explanations as to how they work.

Everybody uses objects nowadays. Something that was not that easy to bet on when PHP5 got released 10 years ago (2005). I still remember this day, I wasn't involved in internals code yet, so I didn't know much things about how all this big machine could work. But I had to note at this time, when using this new release of the language, that jumps had been made compared to old PHP4. The major point advanced for PHP5 adoption was : "it has a new very powerful object model". That wasn't lies. [...] Here, I will show you as usual how all this stuff works internally. The goal is always the same : you understand and master what happens in the low level, to make a better usage of the language everyday.

The article does a great (if lengthy) job of covering everything that happens with PHP's objects and class system, including stats about memory consumption. He includes both the PHP code and the C code to illustrate what's happening with classes, interfaces, traits and object methods/attributes (including object references). He also talks about what "$this" is and how class destructors are handled.

tagged: object class behindthescenes detail c code memory usage

Link: http://jpauli.github.io/2015/03/24/zoom-on-php-objects.html

Pascal Martin:
PHP Version Statistics - October 2014
Oct 28, 2014 @ 11:23:13

Pascal Martin's latest post (in French, but the English version is coming soon) shares some statistics he's gathered around the usage of various software around the web, more specifically those involved in web-based applications.

I've collected statistics about the use of different PHP versions several times. The first time was in September 2011 and the most recent was in November 2013. At this point, PHP 5.2 still accounted for 34.4% of all PHP installations with PHP 5.3 moving up to 48.7%. This new data was collected the weekend of October 19th, 2014. At this point, the current stable versions of PHP are 5.4.34, 5.5.18 and 5.6.2. PHP 5.3 is no longer maintained (since August 14th 2014) and PHP 5.2 hasn't been supported for 4 years now.

He's broken up the statistics into a few different sections:

  • Web server software
  • Usage of major versions of PHP
  • Usage of minor versions of PHP
  • Versions in use under each of the major version numbers

He includes both the raw numbers (percentages) and some graphs showing the results in a bit more consumable fashion. It's interesting to see that, despite it being quite an old version now, PHP 5.3.x still has the largest share in the usage results.

UPDATE: He's posted the English version now as well.

tagged: usage statistics oct2014 version major minor webserver

Link: http://blog.pascal-martin.fr/post/statistiques-versions-php-2014-10

Joshua Thijssen:
Internal PHP function usage: revisited
Aug 06, 2014 @ 11:53:34

Joshua Thjissen has revisited some of his PHP internal function statistics, an update from this previous post with some results showing the most (and least) used internal PHP functions in several large projects from GitHub.

A lot of people are asking about functions like isset, empty, print, echo etc, as they are not present in the current result list. The thing is, is that these are not really functions, but language constructs. This means that PHP treats them a bit different than normal functions, and this results sometimes in seemingly “strange” behaviour when trying to use them like regular functions.

He's updated his results, though, to reflect the usage of these "functions" and shared the numbers. Not surprisingly, these constructs show up pretty highly in the new "top 22" list he's produced. With the inclusion of the constructs, the number one item on the list is now "isset" by a very large margin. The full results can be found in this gist.

tagged: internal function usage statistics github revisit construct language

Link: https://www.adayinthelifeof.nl/2014/08/05/internal-php-function-usage-revisited/