I've started doing my composer installs offline when I foolishly tried to deploy a decently sized PHP project to a VPS with "only" 2GiB of RAM. For some obscure reason Composer eats RAM like it's cake and I couldn't get it to complete fast enough on the server itself.
Composer on shared hosts is a challenge, mostly involving retrying until it works. That's why I fetch most dependencies locally. Sometimes I mess with the dependencies a bit when a specific dependency requires information about how the operating system is configured, but most of the time that's not necessary.