Composer ‘out of memory’ error

I deal with several projects that are written in PHP using the Symfony framework. One of the regular tasks I have to do is to deploy the applications on the production servers. For more than one year I have been successfully using capifony, which after the initial tweaking worked without a problem till last night. The problem was not because of capifony, but it was caused by composer:

I noticed that I was getting the same error on my development machine as well. This was completely independent from my attempts to deploy the project. On the development machine the fix was quite easy and it is listed clearly in the composer’s troubleshooting page. However, my website runs on shared hosting where I cannot change the php.ini file. In the end the solution for deploying the project proved to be very easy. All I had to do was to add the following line in my deploy.rb file:

set :php_bin, "/usr/bin/php -d memory_limit=-1"

the php_bin variable tells capifony where the php interpreter is located, but it seems it also allows to specify command line arguments. After I added this line to deploy.rb, the deployment went smoothly.

Leave a Reply