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 网站上。

上一篇 下一篇
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 0
发起讨论 只看当前版本


暂无话题~