This is my routes.php:
Route::get('/', 'Panel\PanelController@index');
This is my folders:
Http/
....Controllers/
................Panel/
....................../PanelController.php
This is my Controller:
namespace App\Http\Controllers;
class PanelController extends Controller {
/* some code here... */
}
This is what I get:
Class App\Http\Controllers\Panel\PanelController does not exist
I tried the "composer dump-autoload" command but still not working...
You can generate a controller with a subfolder as simple as:
It automatically creates proper namespaces and files with directory. And reference it in routes just as mentioned before:
Happy codding!
The namespace of your class has to match the directory structure. In this case you have to adjust your class and add
Panel
Follow three simple steps
append the folder name in the namespace
Add "use App\Http\Controllers\Controller;" to the controller before the class definition
Add the appended folder name when invoking the controller in any route
There is no need to run "composer dump-autoload"