Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Speeding up Composer autoload

I load two libraries via composer: aws-sdk-php and azure-sdk-for-php. By only loading those libraries I slow down my application's RPS almost by 50%. I don't event instantiate those libraries in my code. They are only loaded by:

require __DIR__ . '/../vendor/autoload.php';

Results with Composer libraries

$ ab -n 1000 -c 50
Requests per second: 813.27 [#/sec] (mean)

Results without Composer libraries:

$ ab -n 1000 -c 50
Requests per second: 1509.20 [#/sec] (mean)

Is there any way to speed things up but still use libraries available in Composer or do I simply need to live with this performance decrease?


Perfect, thanks. After upgrading to PHP 5.5.14 and enabling opcache I was able to speed things up drasticaly:

$ ab -n 1000 -c 50
Requests per second: 2101.23 [#/sec] (mean)
edited Jan '15

You can also use this command in Composer (should increase it a bit more):

--optimize-autoloader (-o): Convert PSR-0/4 autoloading to classmap to get a faster autoloader. This is recommended especially for production, but can take a bit of time to run so it is currently not done by default.