2.13. 命令行工具

未匹配的标注
本文档最新版为 2.0.0,旧版本可能放弃维护,推荐阅读最新版!

The commands that are available will vary depending on which framework you're using. The following table shows the commands available and what framework they're available in.

Laravel Lumen
api:routes
api:cache
api:docs

api:routes

Only available in Laravel 5.1+

This command will generate a table list of your API routes. This command behaves in the exact same way as the route:list command available in Laravel. As well as the standard filtering available you also have the following filters: --versions and --scopes.

Examples
$ php artisan api:routes
$ php artisan api:routes --versions v1
$ php artisan api:routes --scopes read_user_data --scopes write_user_data

api:cache

Only available in Laravel 5.1+

This command will cache your API routes alongside the main application routes. When run this command will also run the route:cache command automatically, so do not run that command after running this command.

Your routes should either appear in the main app/Http/routes.php file or be included within that file for caching to take affect.

Important: Running route:cache by itself will prevent your API routes from being accessible.

Examples
$ php artisan api:cache

api:docs

Available in both Laravel 5.1+ and Lumen 5.1+

This command will generate documentation from your annotated controllers into a standards compliant API Blueprint 1A document. For more on how to annotate your controllers see the API Blueprint Documentation chapter.

By default the command will output the generated documentation to stdout where you can pipe it to a file or push it to a server.

Examples
$ php artisan api:docs --name Example --use-version v2

Output directly to a file with --output-file.

$ php artisan api:docs --name Example --use-version v2 --output-file /path/to/documentation.md

To avoid defining the name and version manually, you can configure defaults in your configuration file or environment file. For more see the configuration chapter.

← API Blueprint Documentation

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 0
发起讨论 只看当前版本


暂无话题~