pomek / path2api
此包已被弃用,不再维护。没有建议的替代包。
Path2API 是一个简单的 Laravel 包,允许您根据类中的 phpDoc 注释生成 API 文档。
1.0.2
2015-04-14 09:08 UTC
Requires
- illuminate/console: ~5.0
- illuminate/filesystem: ~5.0
- illuminate/routing: ~5.0
- illuminate/support: ~5.0
Requires (Dev)
- illuminate/events: ~5.0
- phpspec/phpspec: ~2.0
This package is not auto-updated.
Last update: 2022-04-02 03:39:31 UTC
README
Path2API
Path2API 是一个简单的 Laravel 包,允许您根据类中的 phpDoc 注释生成 API 文档。
包与 Laravel 5 兼容。
安装
- 将包添加到 composer:
composer require "pomek/path2api:1.0.*"
- 发布配置:
php artisan vendor:publish
- 编辑配置文件:
config/path2api.php
- 将服务提供者添加到
app.php
:'Pomek\Path2API\Path2ApiServiceProvider'
- Artisan 命令
path2api:generate
现在将可用。
配置文件
prefix
- API URL 前缀file
- 保存生成的文档的位置before
- 将内容添加到生成的文档上方after
- 将内容添加到生成的文档下方template
- 单条记录的模板
示例
- 示例控制器类
<?php namespace App\Http\Controllers; use App\Http\Requests; class TestController extends Controller { /** * Display a listing of the resource. * * @return Response */ public function index() { // } /** * Show the form for creating a new resource. * * @return Response */ public function create() { // } /** * Store a newly created resource in storage. * * @return Response */ public function store() { // } /** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // } }
- 将资源添加到您的
routes.php
Route::group(['prefix' => 'api'], function () { Route::resource('test', 'TestController'); });
- 通过 CLI 命令生成文档
$ php artisan path2api:generate
File api.md was generated.
- 您的文件
api.md
应该如下所示
# API Documentation Documentation generates by **Path2API** package. --- ### URL: api/test Display a listing of the resource. ### URL: api/test/create Show the form for creating a new resource. ### URL: api/test Store a newly created resource in storage. ### URL: api/test/{test} Display the specified resource. **Params:** * `$id` `int` ### URL: api/test/{test}/edit Show the form for editing the specified resource. **Params:** * `$id` `int` ### URL: api/test/{test} Update the specified resource in storage. **Params:** * `$id` `int` ### URL: api/test/{test} Update the specified resource in storage. **Params:** * `$id` `int` ### URL: api/test/{test} Remove the specified resource from storage. **Params:** * `$id` `int` --- Generates by [Path2API](//github.com/pomek/path2api)