Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

whizdummy's avatar

"php artisan app:name AppName" problem in Laravel 5.1

I am having a problem generating an application name in my project. When I generated php artisan app:name AppName, I encountered this error:

PHP Fatal error:  Uncaught ReflectionException: Class AppName\Console\Kernel does not exist in /home/user/Desktop/AppName/vendor/laravel/framework/src/Illuminate/Container/Container.php:741
...

This is my composer.json file:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "barryvdh/laravel-debugbar": "^2.2",
        "parse/php-sdk" : "1.2.*",
        "graham-campbell/parse": "^2.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

How can I fix this problem? Thanks in advance!

0 likes
2 replies
ahuggins's avatar

Might be the section of the composer.json for "autoload".

By default Laravel is set to autoload the "App" namespace which you are renaming with this command. So the value "App\" needs to be "AppName\" I think. That's where I would start anyway.

1 like
whizdummy's avatar

Ok thanks! I made a separate copy of my project, put it somewhere and re-run php artisan app:name AppName. It finally works like a charm! But I don't know why I encountered error/s when first time issuing that command.

Please or to participate in this conversation.