Laravel upgrade from 4.2 to 5.0, getting [ReflectionException] of class App \ Http \ Controllers \ PagesController does not exist

I updated my project from laravel 4.2 to laravel 5.0. But after I came across this error and try to solve it in the last 4 hours.

I did not encounter such an error as in version 4.2. I tried the composer dump-autoloadwithout effect.

As stated in the upgrade guide, I moved all the controllers as is and made the property namespacein app/Providers/RouteServiceProvider.phpbefore null. So, I think that all my controllers are in the global namespace, so there is no need to add a path anywhere.

Here is my composer .json:

"autoload": {
    "classmap": [
        "app/console/commands",
        "app/Http/Controllers",
        "app/models",
        "database/migrations",
        "database/seeds",
        "tests/TestCase.php"
    ],

Page Controller:

<?php
class PagesController extends BaseController {

  protected $layout = 'layouts.loggedout';

  public function getIndex() {
    $categories = Category::all();

    $messages = Message::groupBy('receiver_id')
                ->select(['receiver_id', DB::raw("COUNT('receiver_id') AS total")])
                ->orderBy('total', 'DESC'.....

And here is BaseController.

<?php

class BaseController extends Controller {

    //Setup the layout used by the controller.
    protected function setupLayout(){
        if(!is_null($this->layout)) {
            $this->layout = View::make($this->layout);
        }
    }

}

In routes.php, I call the controller as follows:

Route::get('/', array('as' => 'pages.index', 'uses' => 'PagesController@getIndex'));

-, , . .

0
1

app/Providers/RouteServiceProvider.php. , :

$router->group(['namespace' => $this->namespace], function($router)
{
    require app_path('Http/routes.php');
});

, App\Http\Controllers, , .

:

  • .
  • , .

# 1, .

0

All Articles