laravel 5.2:未定义命令“优化”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44625918/
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
laravel 5.2: Command "optimize" is not defined
提问by Maahi Negi
I am working on laravel 5.2.
我正在研究 Laravel 5.2。
When I run composer install and composer update command, it show error:
当我运行 composer install 和 composer update 命令时,它显示错误:
[InvalidArgumentException] Command "optimize" is not defined.
Please let me know how to solved this problem.
请让我知道如何解决这个问题。
回答by JoeGalind
This artisan command is deprecated. Simply remove it from your composer.json file.
此工匠命令已弃用。只需从您的 composer.json 文件中删除它。
回答by Muhammad Sulman
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate",
"php artisan jwt:secret -f"
],
"post-install-cmd": [
"Illuminate\Foundation\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\Foundation\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
remove php artisan optimize
from post-install-cmd
array and also from post-update-cmd
than it will look like this.
php artisan optimize
从post-install-cmd
数组中删除,也从post-update-cmd
比它看起来像这样。
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate",
"php artisan jwt:secret -f"
],
"post-install-cmd": [
"Illuminate\Foundation\ComposerScripts::postInstall",
],
"post-update-cmd": [
"Illuminate\Foundation\ComposerScripts::postUpdate",
]
},
working perfectly fine without any warning.
工作得很好,没有任何警告。
回答by Ryan
https://laravel.com/docs/5.6/upgradesays:
https://laravel.com/docs/5.6/upgrade说:
The previously deprecated
optimize
Artisan command has been removed. With recent improvements to PHP itself including the OPcache, theoptimize
command no longer provides any relevant performance benefit. Therefore, you may removephp artisan optimize
from thescripts
within yourcomposer.json
file.
以前不推荐使用的
optimize
Artisan 命令已被删除。随着最近对 PHP 本身的改进,包括 OPcache,该optimize
命令不再提供任何相关的性能优势。因此,你可能会删除php artisan optimize
从scripts
您的内部composer.json
文件。
回答by Krishnamoorthy Acharya
回答by Amitesh
To add of other accepted answer posted :
添加其他已接受的答案:
I face this error while migrating project from laravel5.2 to laravel5.6
我在将项目从 laravel5.2 迁移到 laravel5.6 时遇到了这个错误
Made following change in the composer.json
在 composer.json 中进行了以下更改
Ensure "post-create-project-cmd" of "Scripts" doesn't have "Illuminate\Foundation\ComposerScripts::postInstall", "php artisan optimize" line
Ensure "post-update-cmd" of "Scripts" doesn't have
"Illuminate\Foundation\ComposerScripts::postUpdate", "php artisan optimize" line
确保“脚本”的“post-create-project-cmd”没有“Illuminate\Foundation\ComposerScripts::postInstall”、“php artisan optimize”行
确保“脚本”的“post-update-cmd”没有
“Illuminate\Foundation\ComposerScripts::postUpdate”、“php artisan optimize”行
** Still project didn't run**
** 仍然项目没有运行**
Log file shows "Please provide a valid cache path" error. Run following command from project root and it worked.
日志文件显示“请提供有效的缓存路径”错误。从项目根目录运行以下命令,它工作正常。
mkdir -p storage/framework/{sessions,views,cache}