Home » Php » Composer update memory limit

Composer update memory limit

Posted by: admin November 30, 2017 Leave a comment

Questions:

I need to run composer update at my hosting so I log in with ssh and try to run comand:

composer update

inside /www folder where I have laravel and composer instalation

but I get error:
enter image description here

in contact with my hosting provider they tell me to run command:

php -d memory_limit=512M composer update

I run this command but I get: “Could not open file: composer”

What to do? What is the soluton here?

Answers:

When you run composer update, the OS will look into the configured paths and try to locate an executable file with that name.

When running php composer update, the composer string is treated as a parameter to PHP, which is not searched in any paths. You have to provide the full path in order to run it.

Running which composer will tell you where the OS finds the composer executable, and then you simply use the full path in the PHP command:

$>which composer
/usr/local/bin/composer

$>php -d memory_limit=512M /usr/local/bin/composer update
...

Note that 512MB might be too few. My perception is that it will happily take 1GB or more, depending on the number of dependencies you use and the variety of versions that you theoretically allow, i.e. if you allow Symfony ~2.3, then you make Composer deal with a lot more possible versions compared to using ~2.7.

Also note that running Composer on the production machine is not the best idea. You would have to have access to Github, maybe provide access credentials, have VCS tools installed, and you will easily break your site if any of the remote hosting servers is offline during your update. It is a better idea to use Composer on a deployment system that does all the preparation, and then moves all the files onto the production server.

Leave a Reply

Your email address will not be published. Required fields are marked *