4

I downgraded my application from 5.5 to 5.4 and i am getting this error when i run php artisan serve

Call to undefined method App\Console\Kernel::load() - Laravel 5.4

Looking at other solutions, i run composer dump-autoload to resolve this issue but the issue persist. Same error. I don't really know if this is caused by my packages in the composer.json file posted below

What could i do to resolve this now?

Thanks in advance

Composer.Json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.6.4",
        "barryvdh/laravel-dompdf": "0.8.*",
        "fideloper/proxy": "~4.0",
        "guzzle/guzzle": "~3.0",
        "laravel/framework": "5.4.*",
        "laravel/passport": "^3.0",
        "laravel/tinker": "~1.0",
        "laravelcollective/html": "~5.0",
        "maatwebsite/excel": " ~2.1.0",
        "pda/pheanstalk": "~2.0",
        "picqer/php-barcode-generator": "^0.2.0",
        "spatie/laravel-permission": "^2.12",
        "yajra/laravel-datatables-oracle": "~8.0"
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "nunomaduro/collision": "~1.1",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "~1.0",
        "phpunit/phpunit": "~7.0",
        "symfony/thanks": "^1.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories",
            "app/commands",
            "app/models",
            "app/database/seeds",
            "app/tests/TestCase.php"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}
3
  • delete vendor folder and run composer install again Commented Nov 14, 2018 at 5:49
  • @AnarBayramov i just did ... same error Commented Nov 14, 2018 at 5:53
  • can you delete composer.lock too ? Commented Nov 14, 2018 at 6:11

3 Answers 3

7

The issue is you did not ensure you updated your code to be Laravel 5.4 compatible.

In the Kernel.php boilerplate that comes with Laravel 5.5+ there's the line

$this->load(__DIR__.'/Commands');

This command was added in 5.5 to automatically detect any commands in the app/Console/Commands directory.

In order to get this code to work in 5.4 you need to remove that line and register all your commands manually under the protected $commands = [ ] array in the same file.

The source code for load is in https://github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Console/Kernel.php#L196 if you want to try to adapt it and put it in your own Kernel.php

Sign up to request clarification or add additional context in comments.

Comments

0

Delete vendor folder and composer.lock file after run composer install command

Comments

0

Go to your_project/app/Console/Kernel.php and remove line

$this->load(DIR.'/Commands');

in commands() function

1 Comment

Or it is __DIR__ ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.