Controller exists but Lumen says it does not exist

2

My routes are like this. link < - this is the url I'm requesting

$app->group(['prefix' => 'api/v1'], function($app) {

$app->get('/', 'CommunitiesController@index');

}

Mycontrollerislikethis

<?phpnamespaceApp\Models\Controllers;useApp\Models\Communities;classCommunitiesController{publicfunctionindex(){return"Cheguei no Controller";
    }
}

But the message I get on the request is that

Sorry, the page you are looking for could not be found.
(1/1) NotFoundHttpException

How to resolve?

    
asked by anonymous 02.09.2017 / 02:59

1 answer

1

Beyond the observation of the route that should look like this:

$app->group(['prefix' => 'api/v1'], function($app) 
{
    $app->get('communities', 'CommunitiesController@index');
}

Missing inheritance from the Controller class for your code, the in> is this:

<?php namespace App\Http\Controllers;

use App\Models\Communities;

class CommunitiesController extends Controller
{
    public function index()
    {
        return "Cheguei no Controller";
    }
}

That is, your ComunitiesController has inherited Controller .

02.09.2017 / 03:37