脚本 php artisan clear-compiled 处理返回错误的 pre-update-cmd 事件(Laravel 4.1 升级)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22855602/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error (Laravel 4.1 upgrade)
提问by user1072337
I recently tried upgrading from Laravel 4.0 to Laravel 4.1, and I am getting the follow error when running php composer.phar update:
我最近尝试从 Laravel 4.0 升级到 Laravel 4.1,在运行 php composer.phar 更新时出现以下错误:
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]
I am only requiring:
我只要求:
"require": {
"laravel/framework": "4.1.*",
"way/generators": "2.*",
"madewithlove/laravel-oauth2": "0.4.*"
},
Also, I received this before the error (even though I am running php 5.4.10 in my environment):
另外,我在错误之前收到了这个(即使我在我的环境中运行 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
EDIT:
编辑:
Scripts being used in composer.json:
在 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"
]
},
采纳答案by user2094178
Did you follow the upgrade procedure? Running composer update
won't be enough. laravel.com/docs/upgrade
您是否按照升级程序进行操作?跑步composer update
是不够的。laravel.com/docs/upgrade
回答by Jonny
Maybe you can try this command:
也许你可以试试这个命令:
composer install --no-scripts
回答by jhmilan
Try to remove /bootstrap/compiled.php(I was in trouble downgrading Laravel 4.2 > 4.1)
尝试删除/bootstrap/compiled.php(我在降级 Laravel 4.2 > 4.1 时遇到了麻烦)
Then try to composer update
, it should work.
然后尝试composer update
,它应该可以工作。
Good luck
祝你好运
回答by Duikboot
Try the following in your composer.json. There clear-compiledhandling the pre-update-cmdevent is your error you might clear it.
在您的 composer.json 中尝试以下操作。有clear-compiled处理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"
]
},
Try to run again the following command:
尝试再次运行以下命令:
php composer.phar update
回答by Mahsa Sirous
Worked for me:
为我工作:
After updating composer.jsonper the upgrade guide, to get all updated repo's:
更新 composer.jsonper 升级指南后,获取所有更新的 repo:
composer update --no-scripts
composer update --no-scripts
Then: composer dump-autoload -o
然后: composer dump-autoload -o
Then, I ran an update again so my pre/post update scripts can run: composer update
然后,我再次运行更新,以便我的更新前/更新后脚本可以运行: composer update
App loads in browser and all my tests pass again using 5.2. Hope this helps.
应用程序在浏览器中加载,我所有的测试都使用 5.2 再次通过。希望这可以帮助。
回答by Jimmy Obonyo Abor
If using laravel 5 , then the correct file to delete is services.json
in bootstrap/cache
folder , this error is caused when composer is corrupt due to unfinished update ,
如果使用laravel 5,则要删除的正确文件services.json
在bootstrap/cache
文件夹中,此错误是由于未完成更新而导致composer损坏时引起的,
回答by Rathod Paresh
If none of the other answers work, please try this:
如果其他答案都不起作用,请尝试以下操作:
"pre-update-cmd": [],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],