在使用最新版 Composer 安装 Laravel 的时候,你可能会遇到下面的问题而安装失败:
- $ 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 安装失败。
@Jordi Boggiano 给出的原因如下:
这是由于缺少 composer.lock 文件,因此最初的 install 命令被 update 操作替代,因为它会触发 pre-update-cmd,而在这之前是触发的 pre-install-cmd。
幸运的是,修复这个问题非常简单,只需要把 php artisan clear-compiled 移动到 post-update-command 即可:
这里是完整的 ChangeLog。
来自 http://9iphp.com/web/laravel/laravel-install-fail-update-composer.html