composer: Error when install PHPUnit via composer on shared linux hosting
I’ve installed composer successfully on my Macbook, but when I tried to install composer on my shared linux hosting with “php composer.phar install”, I got the following error.
# php composer.phar install
Content-type: text/html
Fatal error: Uncaught exception 'ErrorException' with message 'Undefined index: argv' in phar:///my_web_apps/system/composer.phar/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php:57
Stack trace:
#0 phar:///my_web_apps/system/composer.phar/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php(57): Composer\Util\ErrorHandler::handle(8, 'Undefined index...', 'phar:///home2/i...', 57, Array)
#1 phar:///my_web_apps/system/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php(98): Symfony\Component\Console\Input\ArgvInput->__construct()
#2 phar:///my_web_apps/system/composer.phar/src/Composer/Console/Application.php(82): Symfony\Component\Console\Application->run(NULL, Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 phar:///my_web_apps/system/composer.phar/bin/composer(39): Composer\Console\Application->run()
#4 /my_web_apps/system/composer.phar(15): require('phar:///ho in phar:///my_web_apps/system/composer.phar/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php on line 57
Here is my composer.json
{
"name": "phpunit",
"description": "PHPUnit",
"require": {
"phpunit/phpunit": "3.7.*"
}
}
Does anyone have any ideas on this? Thx.
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 18 (7 by maintainers)
@curry684 Thanks for this info. I was able to find one cli version of php at
/opt/php-7.0/bin/php
. I could not movecomposer.phar
to/usr/local/bin/composer
due to restrictions so I ended up making a .bash_profile with the code:Now it works fine. Thanks again for the info.
For anyone coming to this issue who don’t have control over their hosting (ie. shared) but also do not have the
php-cli
command, try the following.Don’t forget to give a massive thumbs up to the hosting providers that think giving CLI access to PHP is “dangerous”… And yet still give you SSH access 👍
@curry684, @SaifurRahmanMohsin your advice helped me. cPanel environment running multiple PHP versions. I needed to specify the php.ini config file as referenced below.
into .bashrc
@merhawifissehaye no more issues that if you give people a CLI access to your server but give them the CGI sapi. the security implication is not the fact that the php cli is available, but the fact that the user has access to your server
php-cli composer.phar <command>