Laravel adds Api namespace
PHP中文网
PHP中文网 2017-05-16 16:55:57
0
2
643

You can see that a new api folder has been added to the laravel project

This folder is used for the api interface for external development

The path under the api folder is

api\V1\UserController.php

And when defining routes in routes.php

$api = app('api.router');
$api->version('v1', function ($api) {
    $api->get('users/{id}', 'Api\V1\UserController@show');  
});

The class of this Api\V1\UserController cannot be found

Where do I need to configure the Api namespace? Because the api directory is not registered in laravel at all

Where to configure?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
淡淡烟草味

composer.json

巴扎黑
php$api->version('v1', ['namespace' => 'Api\V1'], function ($api) {
    $api->get('users/{id}', 'UserController@show');
});
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template