I am working on laravel 5.2.
When I run composer install and composer update command, it show error:
[InvalidArgumentException] Command "optimize" is not defined.
Please let me know how to solved this problem.
This artisan command is deprecated. Simply remove it from your composer.json file.
"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.
"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.
https://laravel.com/docs/5.6/upgrade says:
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.
Please note the after install or upgrade laravel following commands will be executed through composer.json file. Since 5.2 onwards optimize command has been depreciated. Please remove it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With