Using Composer on (gs)
I love using MediaTemple for my simple sites. When I don’t have complex hosting requirements, I know I can get my PHP applications up and running really quickly. Their support is great, their hosting fast and feature-rich and their prices competitive.
…but there’s one problem. (gs), their shared hosting platform, has a limited PHP CLI binary. You can’t configure it through a php.ini (see this tweet for more). This makes it impossible to use Composer. Since Composer is the future of PHP, this is quite worrying.
There is, however, a solution. We can use the
-d flag to set the runtime config variables required to get Composer running.
curl -s https://getcomposer.org/installer | php -d allow_url_fopen=1 -d suhosin.executor.include.whitelist=phar
…and then to run composer.phar:
php -d memory_limit=512M -d allow_url_fopen=1 -d suhosin.executor.include.whitelist=phar composer.phar
This is ugly, so let’s clean it up. We’ll add an alias to the bash profile:
$ vim ~/.profile
We’ll alias get_composer to our install command and composer to our composer.phar file. This way we can set up new subdomains and such easily:
alias get_composer="curl -s https://getcomposer.org/installer | php -d allow_url_fopen=1 -d suhosin.executor.include.whitelist=phar" alias composer="php -d memory_limit=512M -d allow_url_fopen=1 -d suhosin.executor.include.whitelist=phar composer.phar"
Save, and reload the profile (this will be done automatically next login):
$ source ~/.profile
Now, we can use Composer to our hearts’ content:
$ get_composer All settings correct for using Composer Downloading... Composer successfully installed to: /blah/domains/efendibooks.com/composer.phar Use it: php composer.phar $ composer -V Composer version cb2a0f4