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