简体   繁体   中英

Not able to install composer in laravel project

I am new in Php and start working on laravel based project but facing one issue when installing composer on project level (I am using Phpstrom Ide).

composer install --no-interaction --ansi Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating optimized autoload files > Illuminate\\Foundation\\ComposerScripts::postInstall > php artisan optimize Script php artisan optimize handling the post-install-cmd event returned with error code 1 Failed to install packages for ./composer.json.

Process :-

  1. Install composer and wamp server
  2. Hit this command in order to create laravel project

composer create-project laravel/laravel --prefer-dist

and project is created with this error and no vendor folder is created

Installing laravel/laravel (v5.4.30) - Installing laravel/laravel (v5.4.30): Downloading (100%) Created project in C:\\wamp64\\www\\laravel

php -r "file_exists('.env') || copy('.env.example', '.env');" Script php -r "file_exists('.env') || copy('.env.example', '.env');" handling th e post-root-package-install event returned with error code 1

  1. I hit the composer command for Install and get first issue in this post

Composer -v

PHP temp directory (D:\\mysql\\temp) does not exist or is not writable to Composer . Set sys_temp_dir in your php.ini Composer version 1.6.5 2018-05-04 11:44:59

composer -version

PHP temp directory (D:\\mysql\\temp) does not exist or is not writable to Composer . Set sys_temp_dir in your php.ini

[Symfony\\Component\\Console\\Exception\\RuntimeException] The "-e" option does not exist.

Exception trace: () at phar://C:/composer/composer.phar/vendor/symfony/console/Input/ArgvInput.p hp:124 Symfony\\Component\\Console\\Input\\ArgvInput->parseShortOptionSet() at phar://C:/c omposer/composer.phar/vendor/symfony/console/Input/ArgvInput.php:105 Symfony\\Component\\Console\\Input\\ArgvInput->parseShortOption() at phar://C:/comp oser/composer.phar/vendor/symfony/console/Input/ArgvInput.php:84 Symfony\\Component\\Console\\Input\\ArgvInput->parse() at phar://C:/composer/compos er.phar/vendor/symfony/console/Input/Input.php:54 Symfony\\Component\\Console\\Input\\Input->bind() at phar://C:/composer/composer.ph ar/vendor/symfony/console/Command/Command.php:200 Symfony\\Component\\Console\\Command\\Command->run() at phar://C:/composer/composer .phar/vendor/symfony/console/Application.php:843 Symfony\\Component\\Console\\Application->doRunCommand() at phar://C:/composer/com poser.phar/vendor/symfony/console/Application.php:193 Symfony\\Component\\Console\\Application->doRun() at phar://C:/composer/composer.p har/src/Composer/Console/Application.php:251 Composer\\Console\\Application->doRun() at phar://C:/composer/composer.phar/vendo r/symfony/console/Application.php:117 Symfony\\Component\\Console\\Application->run() at phar://C:/composer/composer.pha r/src/Composer/Console/Application.php:100 Composer\\Console\\Application->run() at phar://C:/composer/composer.phar/bin/com poser:59 require() at C:\\composer\\composer.phar:24

list [--xml] [--raw] [--format FORMAT] [--] []

[Symfony\\Component\\Console\\Exception\\RuntimeException] The "-e" option does not exist.

Above error comes because of options shortcuts… here composer - version means composer -v … and which is not working in your case. That's the reason behind the last error stack.

Refer this link to see GitHub issue. the -e option does not exist

instead of running composer -version try to run

composer --version

and see it shows composer version or not...if not then the composer is not installed properly.

Then run

laravel --version

if you don't see version there. install composer and laravel again. Below link will be helpful for step by step installation.

laravel new doesn't work

It seems that composer is not properly installed on your environment...

Follow the official documentation and try again to install your dependencies.

Let me know if this solution worked.

01.composer self-update --rollback
02.composer self-update --clean-backups

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM