PHP Composer update "cannot allocate memory" error (using Laravel 4) PHP Composer update "cannot allocate memory" error (using Laravel 4) laravel laravel

PHP Composer update "cannot allocate memory" error (using Laravel 4)


Looks like you runs out of swap memory,try this

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024/sbin/mkswap /var/swap.1/sbin/swapon /var/swap.1

as mentioned by @BlackBurn027 on comments below, this solution was described in here


As composer troubleshooting guide hereThis could be happening because the VPS runs out of memory and has no Swap space enabled.

free -m

To enable the swap you can use for example:

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024sudo /sbin/mkswap /var/swap.1sudo /sbin/swapon /var/swap.1

Or if above not worked then you can try create a swap file

sudo fallocate -l 2G /swapfilesudo chmod 600 /swapfilesudo mkswap /swapfilesudo swapon /swapfile


A bit old but just in case someone new is looking for a solution, updating your PHP version can fix the issue.

Also you should be committing your composer.lock file and doing a composer install on a production environment which is less resource intensive.

More details here:https://github.com/composer/composer/issues/1898#issuecomment-23453850