简体   繁体   中英

Laravel BaseController already in use

I've got this in my routes file:

$api = app('Dingo\Api\Routing\Router');

$api->version('v1',function($api)
{
    $api->group(['prefix' => 'v1'],function($api)
    {
        $api->post('login','App\Http\Controllers\Auth\AuthController@authenticate');
    });

    $api->group(['prefix' => 'v1', 'middleware' => 'jwt.auth'], function($api)
    {
        $api->resource('/user', 'App\Http\Controllers\api\v1\userController');
        $api->post('/authuser','App\Http\Controllers\api\v1\userController@authUser');
    });
});

When I try php artisan api:routes I receive the error:

[Symfony\Component\Debug\Exception\FatalErrorException]                                        
  Cannot use Illuminate\Routing\Controller as BaseController because the name is already in use 

When I comment this:

 //$api->post('login','App\Http\Controllers\Auth\AuthController@authenticate');

The error is gone? What could be wrong?

You can try, by replacing

use Illuminate\Routing\Controller as BaseController

to

use Illuminate\Routing\Controller as CoreController

there would be clashing BaseController

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM