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

Medium.com:
Generating Code Coverage with PHPUnit and phpdbg
Sep 06, 2016 @ 12:36:23

In this post on his Medium page Elton Minetto shows how to generate the code coverage of your PHPunit tests with better performance using phpdbg.

In a previous post (in portuguese) I explained how to identify tests that are taking too long to execute. In this post, I’ll show you how to increase the performance of code coverage report generation using PHPUnit.

In the phpunit.xml file it’s possible to add configurations to generate reports related to the tests that are being executed. [...] In addition to changing the phpunit.xml file, to generate this information we also need to install the extension XDebug. However, by installing it we get a substantial decrease in performance.

He shows an example of the time difference in running the tests (about 1 minute without versus 22 with XDebug). He went looking for a better way and found this post talking about using phpdbg instead. He includes the "brew" commands to get everything you'll need installed and how to use phpdbg with your coverage calls rather than XDebug. However, as is pointed out at the end of the post, the results are slightly different but they're close enough to help you know what code to target next.

tagged: codecoverage phpunit phpdbg results performance tutorial

Link: https://medium.com/@eminetto/generating-code-coverage-with-phpunite-and-phpdbg-4d20347ffb45#.we2bst8uk

Dries Vints:
Two tips to speedup your Laravel tests
Aug 25, 2016 @ 09:15:48

In this recent post to his site Dries Vints shares two quick tips you can use to help speed up the execution of the tests for your Laravel application.

I've seen two different tips for speeding up your tests in Laravel in the past week and thought I'd share them with you. For me, they made a significant impact on the speed of my tests.

His two tips involve lowering the "cost" factor on the number of "rounds" the user password is hashed and the use of a pre-computed hash in your testing factories. These both help reduce the overhead needed, especially when working with tests that need to create the user every time. He includes code and reference links for more information about these two tips and applying them in your testing.

tagged: speed performance laravel test hashing rounds precomputed

Link: https://driesvints.com/blog/two-tips-to-speedup-your-laravel-tests/

Chema Garrido:
Speed test PHP vs Lumen vs Laravel
Aug 18, 2016 @ 12:08:53

Chema Garrido has written up a post sharing some results of a performance test (speed) between Lumen and Laravel also comparing it against Kohana and straight PHP.

I am working in the new EmailValidator!, and after developing the EU VAT API, I feel confident to develop it on Laravel Framework. But before we start… let’s test the speed of the stack.

I used my local computer a 8 cores i7 2ghz 8GB ram 512SSD. Apache2, PHP 7.0.8. Tested this test with siege 5 times for each and retrieved the highest.

The first part of the post shows the results in a tabular format but following this is the more detailed version, complete with the siege command executed and the code used. The results are interesting but seem to mostly fall into the real of micro-optimization as there's really not that much difference between the results (though the "Longest transaction" on the plain PHP code is an oddity).

tagged: laravel lumen performance speed test results framework

Link: https://chema.ga/speed-test-php-vs-lumen-vs-laravel/

SitePoint PHP Blog:
Can Symfony Apps Be Fast on Vagrant? Let’s Check with SuluCMS!
Jun 28, 2016 @ 12:13:15

On the SitePoint PHP blog they've posted a new tutorial looking at the combination of Symfony applications (well, one specific one) and Vagrant to optimize it for the best performance possible.

In this short tutorial, we’ll set up Sulu, a new Symfony based CMS, and optimize it on a Vagrant environment. Why a dedicated tutorial handling this? Besides the fact that Sulu has a rather complex initialization procedure, it is based on Symfony which is infamously slow on virtual machines with shared filesystems, and thus needs additional optimizations post-install. The performance hacks in this post, while Sulu-specific, can be applied to any Symfony application to make it faster on Vagrant.

The rest of the post walks you through the steps to get the box set up and the Sulu application up and running:

  • New Box and Folder Sharing
  • App Type and Vagrant Boot (configuration)
  • Installing Sulu

Then they get into the speed improvements and "hacks" to make the overall system perform better. They make updates to the log/cache directory fetching, moving the "vendors" folder into the VM (non-synced) and enabling the APC caching on autoloading. The tutorial also includes a few helpful troubleshooting tips of things to check if a problem does happen to pop up.

tagged: tutorial symfony application vagrant sulucms performance

Link: https://www.sitepoint.com/symfony-on-vagrant-performance-hacks-sulucms-case-study/

Alejandro Celaya:
Using ServiceManager 3 lazy services to improve your PHP application performance
Jun 13, 2016 @ 10:20:18

Alejandro Celaya has posted a tutorial to his site showing you how to use ServiceManager 3 to improve performance in your PHP-based application. The ServiceManager is a piece of the Zend Framework.

Performance is an important subject when a project grows. There are some good practices that make projects more maintainable, like dependency injection, however, creating all the objects at the beginning of the request could reduce the application performance. If some of the created objects are not finally used, we have wasted CPU time and memory for no reason.

If we used proxies for every expensive dependency, the previous problem would be solved. We can still inject the dependency, but it will be wrapped by the proxy, which will create the object itself once we need it, or never, if it is not finally used. This is the principle behind lazy services. The ServiceManager makes use of the ocramius/proxy-manager package to create proxies on the fly for all the services configured as lazy.

He talks about the lazy_services functionality the ServiceManager provides and gives an example of it in use defining a database (PDO) connection. He talks some about how it works behind the scenes and how no code change is required to use this new configuration.

tagged: performance application servicemanager3 lazy services example tutorial zendframework

Link: http://blog.alejandrocelaya.com/2016/06/12/using-service-manager-3-lazy-services-to-improve-your-php-application-performance/

SitePoint PHP Blog:
Benchmarking: Can AppServer Beat Symfony’s Performance?
May 19, 2016 @ 10:45:51

The SitePoint PHP blog has posted a new article comparing AppServer and Symfony on a performance level and wonders if the AppServer platform can outperform the framework on some base level functionality.

After the release of the first part of our Appserver series, it was clear through the ensuing discussions on both SitePoint and Reddit that we had touched a nerve for a good number of PHP channel’s devoted readers. I also quickly realized this new (for PHP) technology had a good number of serious doubters. One of the most poignant responses in the discussions was something along the lines of,

Needless to say, those doubtful and critical comments sounded like a real challenge. I was also very interested in finding out where appserver would land, if it were to be benchmarked against another well known PHP framework. [...] I decided to use my favorite framework, Symfony, to make the comparison. This is because appserver, as a stock PHP application server, also offers a good bit of important application functionality similar to Symfony.

They start with the approach they took to the comparison and how they set up the systems to evaluate the difference between the two (including hardware specs). The remainder of the post shares the results of several Apache Bench runs - the raw command line output - and more graphical versions of the same information (bar graphs). While there are a few "wins" on the AppServer side, overall it came in a bit slower (mostly because of the technologies involved in every request, however).

tagged: appserver appserverio performance symfony comparison benchmark results

Link: https://www.sitepoint.com/benchmarking-can-appserver-beat-symfonys-performance/

Three Devs & A Maybe:
Episode 96 - Application Performance with Jonathan Klein
May 11, 2016 @ 11:57:30

In the latest episode of the Three Devs and a Maybe podcast hosts Michael Budd, Fraser Hart, Lewis Cains and Edd Mann talk with Jonathan Klein about application performance based on some of his work creating the "High Performance PHP" course for Pluralsight.

On this weeks episode we are joined by Jonathan Klein to discuss all things application performance. We start off the show with chat about how he got into performance, why it is so important and how he thinks of it throughout the development process. From here we discuss his recently released Pluralsight course on ‘High Performance PHP’ and touch upon some of the key performance areas within the stack.

Starting with micro-optimisations at the code level, we highlight their value and caching mechanisms. We then move onto the web server, process managers and the importance of a correct configuration. The Database layer is then brought up, discussing forks of MySQL, handling slow-queries and data-denormalizations. Finally, profiling and monitoring tools are discussed (such as New Relic and Seige) and where you can typically find the most wins within a typical stack.

They talk about his Pluralsight course as well as other topics like feature flagging, caching, atomic deployments and MariaDB vs MySQL. You can listen to this latest episode either through the in-page audio player or by downloading the mp3 directly. If you enjoy the show, be sure to also subscribe to their feed to get the latest shows as they're released.

tagged: threedevsandamaybe ep96 application performance jonathanklein podcast

Link: http://threedevsandamaybe.com/application-performance-with-jonathan-klein/

Tideways.io:
PHP Session Garbage Collection: The unknown performance bottleneck
May 09, 2016 @ 12:49:22

On the Tideways.com blog there's a tutorial talking about the "unknown performance bottleneck" that can be caused by PHP's own session garbage collection. This garbage collection happens when sessions expire and they need to be removed from the current set/data source.

Here is one performance setting in your PHP configuration you probably haven't thought about much before: How often does PHP perform random garbage collection of outdated session data in your application? Did you know that because of the shared nothing architecture PHP randomly cleans old session data whenever session_start() is called? An operation that is not necessarily cheap.

It's his general advice to avoid PHP's random garbage collection (it happens one in every 1000 requests, randomly) and opt for a more consistent method using background scripts. He gives an example using the Laravel framework and it's modified session garbage collection happening every 50th request (making use of the Symfony Finder component). He points out the problem with its implementation and the negative impact it could have on large, highly used applications. They share some of their own statistics and how to change this default (modifying the lottery option and making a custom "cleanup" command).

tagged: session garbage collection performance bottleneck unknown modify laravel symfony

Link: https://tideways.io/profiler/blog/php-session-garbage-collection-the-unknown-performance-bottleneck

Symfony Finland:
Universal Rendering in PHP/Twig could be done with the Angular 2 Template Compiler
May 09, 2016 @ 11:15:01

The Symfony Finland site has a post about Angular 2, its server-side rendering support and how Symfony can fit into the picture.

At the ng-conf event in May 2016 there were sessions discussing how Angular 2 can support server side rendering in various platforms. If you're working on a project running on Node.js, then Angular 2 is a native citizen. For other options like ASP, Java and PHP there are a few options on the table.

[...] Later during the ng-conf more details on the Server Side Rendering (Universal Rendering in Angular lingo) can be implemented in different environments to improve first page load experience. [...] The downside of these approaches is that you need to add additional complexity either by adding a dependency to an external service or require a rather exotic PHP extension at this point.

Instead he suggests using Twig along with the Angular 2 template compiler and some custom extensions to the base templating to format the output as Angular is expecting it. He talks about how the current backend rendering of templates could easily be translated to this handling. He also suggests that even just partial server-side rendering might be enough to help with the performance of the application.

tagged: symfony universalrendering angular2 twig template backend frontend performance

Link: https://www.symfony.fi/entry/universal-rendering-in-php-twig-with-angular-2-template-compiler

Marc Schmidt:
PHP High-Performance - Follow Up with Symfony/Jarves.io and PHP-PM
May 02, 2016 @ 12:08:37

In a follow up to his previous article about high performance PHP with React's help, Marc Schmidt has returned with a follow up post two years after the fact with some updates and additional information.

This is a follow up article on “Bring High Performance Into Your PHP App”, which went quiet viral with over 100k visits. This does not only show that many people still struggle with PHP and its performance, but also that people are highly interested in a solution to this kind of issues. PHP-PM could be one solution. But first things first. Over two years later since my blog post about high-performance things have changed dramatically.

[...] When I hacked together some lines of code back then in 2013 I never though that this kind of application style would ever succeed in the PHP world. [...] However, things have changed there as well.

He talks about some of the advancements that have been made since his previous post including PHP 7, improvements in PHP-FM and the HttpKernel component of the Symfony framework. Along the lines of bringing even more performance to PHP applications with React, they created an adapter to link the two. The post covers some of the currently open issues, the "good things" about it and some of the design issues to keep in mind when using it. He ends the post talking about where the PHP-PM project is now and some of the benchmarks about performance between PHP-PM and PHP-FPM.

tagged: performance react httpkernel phppm phpfpm adapter benchmark

Link: http://marcjschmidt.de/blog/2016/04/16/php-high-performance-reactphp-jarves-symfony-follow-up.html