Why does my application crash when changing my namespace?

I follow the material given in Easy Laravel 5 to get to know Laravel. Therefore, I created the application for the intended purpose, and when I visited localhost:8000 , I saw a welcome page.

Then I gave a command to change the name:

 php artisan app:name todoparrot 

What the system answered Application namespace set! . But now, when I restart localhost:8000 , I see nothing, and the terminal serving the application gives me a long list of errors:

 PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class todoparrot\Console\Kernel does not exist' in /media/common/htdocs/todoparrot/vendor/laravel/framework/src/Illuminate/Container/Container.php:776 Stack trace: #0 /media/common/htdocs/todoparrot/vendor/laravel/framework/src/Illuminate/Container/Container.php(776): ReflectionClass->__construct('todoparrot\Cons...') #1 /media/common/htdocs/todoparrot/vendor/laravel/framework/src/Illuminate/Container/Container.php(656): Illuminate\Container\Container->build('todoparrot\Cons...', Array) #2 /media/common/htdocs/todoparrot/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(613): Illuminate\Container\Container->make('todoparrot\Cons...', Array) #3 /media/common/htdocs/todoparrot/vendor/laravel/framework/src/Illuminate/Container/Container.php(229): Illuminate\Foundation\Application->make('todoparrot\Cons...', Array) #4 /media/common/htdocs/todoparrot/vendor/laravel/framework/src/Illuminate/Container/Container.php(773): Illuminate\Container\Con in /media/common/htdocs/todoparrot/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 776 

Now I can’t even start artisan since I keep getting the same error. Any idea what might be broken due to this extremely simple change?

+7
laravel laravel-5 composer-php
source share
3 answers

Try this command after renaming:

 composer dump-autoload 
+13
source share

If you run the command below, it will change the entire namespace and path to todoparrot. In your case, Laravel was not found "Class todoparrot \ Console \ Kernel does not exist." Make sure the namespace has been changed to todoparrot

 php artisan app:name todoparrot 

The command will modify all files below

 modified: app/Commands/Command.php modified: app/Console/Commands/Inspire.php modified: app/Console/Kernel.php modified: app/Events/Event.php modified: app/Exceptions/Handler.php modified: app/Http/Controllers/Auth/AuthController.php modified: app/Http/Controllers/Auth/PasswordController.php modified: app/Http/Controllers/Controller.php modified: app/Http/Controllers/HomeController.php modified: app/Http/Controllers/WelcomeController.php modified: app/Http/Kernel.php modified: app/Http/Middleware/Authenticate.php modified: app/Http/Middleware/RedirectIfAuthenticated.php modified: app/Http/Middleware/VerifyCsrfToken.php modified: app/Http/Requests/Request.php modified: app/Http/routes.php modified: app/Providers/AppServiceProvider.php modified: app/Providers/BusServiceProvider.php modified: app/Providers/ConfigServiceProvider.php modified: app/Providers/EventServiceProvider.php modified: app/Providers/RouteServiceProvider.php modified: app/Services/Registrar.php modified: bootstrap/app.php modified: composer.json modified: config/app.php modified: config/auth.php 

Example in app / Console / Kernel.php command will change this value

 namespace App\Console; protected $commands = [ 'App\Console\Commands\Inspire', ]; 

For

 namespace todoparrot\Console; protected $commands = [ 'todoparrot\Console\Commands\Inspire', ]; 

Please check the app / Console / Kernel.php file if the Application path is still available. If available, go to "todoparrot".

I already tried running the command "php artisan app: name todoparrot". It's not a problem. I do not know why this will throw your mistake.

+1
source share

From Ggo to C: \ wamp \ www \ laravel \ at the command line use

 C:\ProgramData\ComposerSetup\bin\composer dump-autoload 

instead

 composer dump-autoload 
-one
source share

All Articles