安裝 Laravel 遇到問題?你須要更新 composer.json 文件

 

轉載自 https://9iphp.com/web/laravel/laravel-install-fail-update-composer.html

在使用最新版 Composer 安裝 Laravel 的時候,你可能會遇到下面的問題而安裝失敗:php

 

$ php composer.phar create-project --prefer-dist laravel/laravel blog
Installing laravel/laravel (v5.2.15)
- Installing laravel/laravel (v5.2.15)
Loading from cache

Created project in blog
> php -r "copy('.env.example', '.env');"
> php artisan clear-compiled
PHP Warning: require(/home/vagrant/laraveltest/blog/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/laraveltest/blog/bootstrap/autoload.php on line 17
PHP Fatal error: require(): Failed opening required '/home/vagrant/laraveltest/blog/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/vagrant/laraveltest/blog/bootstrap/autoload.php on line 17
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error


[RuntimeException] 
Error Output: PHP Warning: require(/home/vagrant/laraveltest/blog/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/laraveltest/bl 
og/bootstrap/autoload.php on line 17 
PHP Fatal error: require(): Failed opening required '/home/vagrant/laraveltest/blog/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/vagr 
ant/laraveltest/blog/bootstrap/autoload.php on line 17

create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>]

這是因爲 Composer 最近更新了 pre-update-command 的工做方式,而這會使得 Laravel 安裝失敗。html

@Jordi Boggiano 給出的緣由以下:laravel

這是因爲缺乏 composer.lock 文件,所以最初的 install 命令被 update 操做替代,由於它會觸發 pre-update-cmd,而在這以前是觸發的 pre-install-cmd。
幸運的是,修復這個問題很是簡單,只須要把 php artisan clear-compiled 移動到 post-update-command 便可:web

相關文章
相關標籤/搜索