Selectcomposer require darkaonline/l5-swagger Using version ^5.6 for darkaonline/l5-swagger ... - Installing swagger-api/swagger-ui (v3.17.4) - Installing doctrine/annotations (v1.6.0) - Installing zircote/swagger-php (2.0.13) - Installing darkaonline/l5-swagger (5.6.5) ...Run
php artisan vendor:publish
L5Swagger\L5SwaggerServiceProvider
ThisTwo files will be added at this time
/config/l5-swagger.php
/resources/views/vendor/l5-swagger/index.blade.php
- Configuration
- Add a comment before class
app/Http/Controllers/Controller.php
fileRun command
php artisan l5-swagger:generateOpen your project URL
http://localhost/api/documentation, you will see that swagger has run successfully, but no API documentation is displayed. Write documentationExample: index
Get
http://localhost/homemethod in
HomeController
Write the document/** * @SWG\Get( * path="/home", * summary="用户资料", * @SWG\Response(response=200, description="请求成功"), * @SWG\Response(response=401, description="用户验证失败"), * @SWG\Response(response=500, description="服务器错误") * ) * */ public function index() { return view('home'); }above and run the command again
php artisan l5-swagger:generateGo back to
http://localhost/api/documentation to refresh, the document will be out, it should look like this AppearanceThe latest five Laravel video tutorials
Recommended: