Home  >  Article  >  Backend Development  >  安装 Laravel 遇到问题?你需要更新 composer.json 文件

安装 Laravel 遇到问题?你需要更新 composer.json 文件

WBOY
WBOYOriginal
2016-06-23 13:13:071594browse

在使用最新版 Composer 安装 Laravel 的时候,你可能会遇到下面的问题而安装失败:

$ php composer.phar create-project --prefer-dist laravel/laravel blogInstalling laravel/laravel (v5.2.15)  - Installing laravel/laravel (v5.2.15)    Loading from cacheCreated project in blog> php -r "copy('.env.example', '.env');"> php artisan clear-compiledPHP 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 17PHP 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 17Script 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。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn