我最近尝试从Laravel 4.0升级到Laravel 4.1,运行php composer.phar update时出现以下错误:
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
[RuntimeException]
Error Output:
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [packagesN]
我只要求:
"require": {
"laravel/framework": "4.1.*",
"way/generators": "2.*",
"madewithlove/laravel-oauth2": "0.4.*"
},
另外,我在错误之前收到了这个(即使我在我的环境中运行php 5.4.10):
phpseclib/phpseclib suggests installing ext-gmp (Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.)
phpseclib/phpseclib suggests installing pear-pear/PHP_Compat (Install PHP_Compat to get phpseclib working on PHP < 4.3.3.)
d11wtq/boris suggests installing ext-readline (*)
d11wtq/boris suggests installing ext-pcntl (*)
Writing lock file
Generating autoload files
编辑:
在composer.json中使用的脚本:
"scripts": {
"pre-install-cmd": [
"php artisan clear-compiled"
],
"post-install-cmd": [
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
答案 0 :(得分:7)
您是否遵循了升级程序?运行composer update
是不够的。 laravel.com/docs/upgrade
答案 1 :(得分:7)
尝试删除 /bootstrap/compiled.php (我无法降级Laravel 4.2&gt; 4.1)
然后尝试composer update
,它应该有用。
答案 2 :(得分:6)
也许你可以尝试这个命令:
composer install --no-scripts
答案 3 :(得分:5)
在composer.json中尝试以下操作。 处理 pre-update-cmd 事件的清除编译是您可能清除它的错误。
"scripts": {
"pre-install-cmd": [
"php artisan clear-compiled"
],
"post-install-cmd": [
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
]
},
尝试再次运行以下命令:
php composer.phar update
答案 4 :(得分:3)
如果使用laravel 5,那么要删除的正确文件是services.json
文件夹中的bootstrap/cache
,这个错误是由于未完成更新而导致编写器损坏时引起的,
答案 5 :(得分:2)
为我工作:
按照升级指南更新composer.json后,即可获取所有更新的存储库:
composer update --no-scripts
然后:composer dump-autoload -o
然后,我再次运行更新,以便我的更新前/更新脚本可以运行:composer update
应用程序在浏览器中加载,并且我所有的测试都使用5.2通过。希望这会有所帮助。
答案 6 :(得分:1)
如果其他答案都不起作用,请尝试:
"pre-update-cmd": [],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],