George Panayi
George Panayi

Reputation: 1772

ReflectionException in Container.php line 776: Class APPPATH\Http\Controllers\DashboardController does not exist

I know that this error exist in many posts but I tried everything without any solution. After I changed the value model in the auth.php file, to the correct path of the user model, my controllers are not working. All of the controllers throwing the following issue but only the Auth controller is working fine. The error message that I'm getting is:

ReflectionException in Container.php line 776: Class APPPATH\Http\Controllers\DashboardController does not exist

I made composer dump-autoload but still the same. My controller is inside App\Http\Controllers\Administrator\Dashboard\DashboardController.php

namespace APPPATH\Http\Controllers;

    class DashboardController extends Controller {}

and inside my route i have this

get('/', array('as' => 'administrator.dashboard', 'uses' => 'DashboardController@index'));

get('/dashboard', array('as' => 'administrator.dashboard', 'uses' => 'DashboardController@index'));

get('/dashboard/index', array('as' => 'administrator.dashboard', 'uses' => 'DashboardController@index'));

Here is the composer of laravel 5

"autoload": { "classmap": [ "database" ], "psr-4": { "APPPATH\": "app/" } },

Does anyone knows why is not working? Thank you

The error message

ReflectionException in Container.php line 776:

Class APPPATH\Http\Controllers\DashboardController does not exist in Container.php line 776

at ReflectionClass->__construct('APPPATH\Http\Controllers\DashboardController') in Container.php line 776

at Container->build('APPPATH\Http\Controllers\DashboardController', array()) in Container.php line 656

at Container->make('APPPATH\Http\Controllers\DashboardController', array()) in Application.php line 620

at Application->make('APPPATH\Http\Controllers\DashboardController') in ControllerDispatcher.php line 83

at ControllerDispatcher->makeController('APPPATH\Http\Controllers\DashboardController') in ControllerDispatcher.php line 54

at ControllerDispatcher->dispatch(object(Route), object(Request), 'APPPATH\Http\Controllers\DashboardController', 'index') in Route.php line 198

at Route->runWithCustomDispatcher(object(Request)) in Route.php line 131

at Route->run(object(Request)) in Router.php line 691

at Router->Illuminate\Routing{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141

at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101

at Pipeline->then(object(Closure)) in Router.php line 693

at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 660

at Router->dispatchToRoute(object(Request)) in Router.php line 618

at Router->dispatch(object(Request)) in Kernel.php line 214

at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141

at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in VerifyCsrfToken.php line 43

at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17

at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125

at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in ShareErrorsFromSession.php line 55

at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125

at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in StartSession.php line 61

at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125

at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36

at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125

at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in EncryptCookies.php line 40

at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125

at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in CheckForMaintenanceMode.php line 42

at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125

at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101

at Pipeline->then(object(Closure)) in Kernel.php line 115

at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84

at Kernel->handle(object(Request)) in index.php line 53

Upvotes: 2

Views: 4652

Answers (4)

Shahrukh Anwar
Shahrukh Anwar

Reputation: 2632

If your file exists in App\Http\Controllers\Administrator\Dashboard\DashboardController.php, then first your given namespace is incorrect and the second thing is in your routes.php you are sending it in DashboardController which assumes that it will present directly after the controllers directory. Try the below changes.

  • In your DashboardController.php

    namespace APPPATH\Http\Controllers\Administrator\Dashboard;
    
    class DashboardController extends Controller {
    
    }
    
  • In your routes.php, change your route as below

    get('/', array('as' => 'administrator.dashboard', 'uses' => 'Administrator\Dashboard\DashboardController@index'));
    

I hope this will work.

Upvotes: 0

FULL STACK DEV
FULL STACK DEV

Reputation: 15971

get('/', array('as' => 'administrator.dashboard', 'uses' => '\APPPATH\Http\DashboardController@index'));

It will try to get it from root namespaces

Upvotes: 0

Md Aman Ullah
Md Aman Ullah

Reputation: 506

For my case I was getting this error for some authentication issue. I get resolved the issue by following the simple 2 steps in L5.1 :

  1. Put "league/oauth2-server": "4.1.*" on the require section of your composer.json file.
  2. run 'composer update' command on terminal.

You can try also. Thanks

Upvotes: 1

dynamic
dynamic

Reputation: 48141

Should be App, not APPPATH

namespace App\Http\Controllers;

Upvotes: 1

Related Questions