Skip to content
Advertisement

how to make a directory in controller – laravel

I created a Panel directory inside Controller directory .

enter image description here

there is a login function inside AdminController.php

JavaScript

in routes.php I wrote a route like this:

JavaScript

but when I run below url I got some errors that there isn’t exist this controller :

http://localhost:8000/cp/login

ReflectionException in Route.php line 280: Class AppHttpControllersPanelAdminController does not exist

Advertisement

Answer

Try adding the appropriate namespace to the top of the AdminController file, you will also need to specify the namespace for the Controller class that it extends, as they are under different sub-namespaces.

You can read more about PSR-4 autoloading here http://www.php-fig.org/psr/psr-4/.

Based on the directory structure that you have there it should read

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement