Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel 5.2: Command "optimize" is not defined

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.

like image 364
Maahi Negi Avatar asked Jun 19 '17 08:06

Maahi Negi


4 Answers

This artisan command is deprecated. Simply remove it from your composer.json file.

like image 119
JoeGalind Avatar answered Nov 13 '22 20:11

JoeGalind


"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.

like image 32
Muhammad Sulman Avatar answered Nov 13 '22 21:11

Muhammad Sulman


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, the optimize command no longer provides any relevant performance benefit. Therefore, you may remove php artisan optimize from the scripts within your composer.json file.

like image 32
Ryan Avatar answered Nov 13 '22 21:11

Ryan


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.enter image description here

like image 1
Krishnamoorthy Acharya Avatar answered Nov 13 '22 20:11

Krishnamoorthy Acharya