If composer runs out of memory on digitalocean or another RAM limited cloud VM You need to create a swap drive
Create and activate the swapdrive as superuser And get back to the normal shell
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=8192
sudo chmod 600 /var/swap.1
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
After finishing up the swapdrive can be removed
sudo /sbin/swapoff /var/swap.1
sudo rm /var/swap.1
or from a root shell
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=8192
chmod 600 /var/swap.1
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1
/sbin/swapoff /var/swap.1
rm /var/swap.1