Riduidel Riduidel - 5 years ago 404
PHP Question

Using composer with php in non standard location

I'm trying to use composer on my NAS (a good old D-Link DNS-323 running the incredibly good fonz fun plug 0.7).

I have my php installed in

/ffp/bin/php
.

When I install composer using the following command

php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/ffp/sbin --filename=composer


But when I do a simple
less /ffp/sbin/composer
, I have the following shebang set :

#!/usr/bin/env php
<?php
/*
* This file is part of Composer.
*


Unfortunatly, my NAS do not have the
/usr/bin/env
folder existing on my machine ...
So, how can I have composer referring to the correct php executable ?

Besides, I tried changing the declaration to use
#!/ffp/bin/php
, but when doing so, any composer run echoes the following result :

PHP Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/gd.so' - File not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/gd.so' - File not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/sqlite.so' - File not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/sqlite.so' - File not found in Unknown on line 0
PHP Fatal error: Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23
Stack trace:
#0 /mnt/HD_a2/ffp/sbin/composer(23): Phar::mapPhar('composer.phar')
#1 {main}
thrown in /mnt/HD_a2/ffp/sbin/composer on line 23
Fatal error: Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23
Stack trace:
#0 /mnt/HD_a2/ffp/sbin/composer(23): Phar::mapPhar('composer.phar')
#1 {main}
thrown in /mnt/HD_a2/ffp/sbin/composer on line 23


Of particular importance is the line

PHP Fatal error: Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23


How can i fix it ? In other words, how can I have a working php + composer installation on my NAS ?

Answer Source

So, how can I have composer referring to the correct php executable ?

A very simple solution is to create a shell script:

#!/bin/sh
/ffp/bin/php -n /ffp/sbin/composer "$@"

Make it executable, name it composer, put it in your path before /ffp/sbin (or rename /ffp/sbin/composer to composer.phar and update the above script too).

The -n flag tells PHP to not use php.ini. This is useful when there are many extensions loaded from php.ini; not loading them makes composer run faster. Especially xdebug is recommended to not be loaded by composer, for speed improvement.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download