Path2API is a simple Laravel package which allows you generate API documentation based on phpDoc comments in your classes.
Package is compatible with Laravel 5.
- Add package to composer:
composer require "pomek/path2api:1.0.*" - Publish configuration:
php artisan vendor:publish - Edit configuration file:
config/path2api.php - Add Service Provider to
app.php:'Pomek\Path2API\Path2ApiServiceProvider' - Artisan Command
path2api:generatewill be available now.
prefix- API URL prefixfile- where will save generated documentationbefore- content will be added above the generated documentationafter- content will be added below the generated documentationtemplate- template for a single record
- Example Controller class:
<?phpnamespaceApp\Http\Controllers;
useApp\Http\Requests;
class TestController extends Controller
{
/** * Display a listing of the resource. * * @return Response */publicfunctionindex()
{
//
}
/** * Show the form for creating a new resource. * * @return Response */publicfunctioncreate()
{
//
}
/** * Store a newly created resource in storage. * * @return Response */publicfunctionstore()
{
//
}
/** * Display the specified resource. * * @param int $id * @return Response */publicfunctionshow($id)
{
//
}
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */publicfunctionedit($id)
{
//
}
/** * Update the specified resource in storage. * * @param int $id * @return Response */publicfunctionupdate($id)
{
//
}
/** * Remove the specified resource from storage. * * @param int $id * @return Response */publicfunctiondestroy($id)
{
//
}
}- Add resource to your
routes.php
Route::group(['prefix' => 'api'], function () {
Route::resource('test', 'TestController');
});- Generate documentation by CLI command
$ php artisan path2api:generate
File api.md was generated.
- Your file
api.mdshould be like:
# 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)