0
votes

I am new developer on Laravel, now I'm using Laravel version 5.5

I got the problem after used php artisan app:name on my project, I got the problem:

In ProviderRepository.php line 208: Class 'App\Providers\AppServiceProvider' not found

as the captured image below:

enter image description here

As this error, I can not use php artisan commands or composer commands anymore can you guys please help me to solve this problem I am really appreciated for time. Thanks you

Best Regards Siripong Gaewmaneechot

2
If you've opened it, you might have appended something to the name space, added a space before <?php or removed the entire opening php declaration - connormcwood

2 Answers

1
votes

I would suggest looking in your config files, and the main classes which were generated when you started your laravel project (User class, etc) because they are all set to App\User App..... etc.

So for example, in the image you have in the question, it says it can not find App\AppProviders... - This indicates that somewhere you still have a use statement pointed to App\AppProviders.. but you changed the app name, so it's no longer App. something I do if I made that mistake, is I do a global search in my project files for App\ (you may need to put App\\ in the search because \ is an escape character

So if you did not change the app name immediately after starting the project, some of the paths will not be pointing to the correct directories. Let me know if that makes sense.

0
votes

The command changes the PSR-4 configuration in composer.json.

Assume it was App before, your composer.json looks like this:

"autoload": {
    "psr-4": {
        "App\\": "app/"
    }
},

After running the command with php artisan app:name Foo, it will look like:

"autoload": {
    "psr-4": {
        "Foo\\": "app/"
    }
},

Therefore the whole namespace has changed and your classes can't be found by the Autoloader. To fix this, you have to either go back to the old name or do a global search and replace to change the namespace from App to Foo.