Skip to content

Controller instantiated 9 times #28

@gabrielkoerich

Description

@gabrielkoerich

Not sure if I'm doing something wrong, but if I try to use a Route::resource(), the __constructor() method is called lots of times.

Code:

Route::api(['version' => 'v1', 'prefix' => 'api'], function()
{
    Route::resource('user', 'App\Modules\User\Controllers\UserController');
});
use Dingo\Api\Dispatcher;
use Dingo\Api\Auth\Shield;
use Dingo\Api\Routing\Controller;

class UserController extends Controller {

   public function __construct(Dispatcher $api, Shield $auth)
   {
       $this->api = $api;
       $this->auth = $auth;

       echo 'test'; 
   }

   //...
}

In this case 'test' is called exactly 9 times. Is it ok to use resource controllers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions