In Laravel 5, an βapplicationβ is a collection of PHP files under one namespace stored in the app/ folder
By default, and in most Laravel 5 code examples from documents, this is the App\ namespace. For example, one controller in your application might look like this.
namespace App\Http\Controller; class MyController {
When Laravel generates code (i.e. when you use the make:request command), he needs to know that this is the application namespace (it is possible to change the namespace using the artisan app:name command). For some reason, Laravel 5 cannot determine the namespace on your system.
If you look at the section of the main Laravel 5 code that defines the namespace
#File: vendor/laravel/framework/src/Illuminate/Console/AppNamespaceDetectorTrait.php protected function getAppNamespace() { $composer = json_decode(file_get_contents(base_path().'/composer.json'), true); foreach ((array) data_get($composer, 'autoload.psr-4') as $namespace => $path) { foreach ((array) $path as $pathChoice) { if (realpath(app_path()) == realpath(base_path().'/'.$pathChoice)) return $namespace; } } throw new RuntimeException("Unable to detect application namespace."); }
You will see Laravel discover the namespace by looking at your composer.json file and looking for the first true psr-4 namespace.
My guess is that your composer.json file is missing a namespace
"autoload": { "classmap": [ "database" ], "psr-4": { "App\\": "app/" } },
Add this back and you will be fine.
source share