I have a simple website on Laravel with different types of entries and categories. I need to create documentation for him. I tried to install phpDocumentor, but it is not installed on Laravel latest version. Also I should clarify that this is not the API of the project a simple website. What other solutions do you have for automatically generating documentation?
laravel will generate the documentation as a Blade view within the resources/views/apidoc folder, so you can add routing and authentication to your liking. In both instances, the source markdown file will be generated in resources/docs/source .
To generate your API documentation, use the apidoc:generate artisan command. It will generate documentation using your specified configuration. The documentation will be generated as static HTML and CSS assets within the specified output folder.
If you want to create documentation for routes, you can try laravel-routes.
This package can be installed with composer with the next command:
composer require gussrw/laravel-routes
You can generate the HTML file from the console with the next artisan command.
php artisan route:docs
This command creates an HTML file in Project/docs.
Route description
The description is optional, but if you want to add them create a PHP comment over each route in the web.php file with @description.
/**
* @description Show the home page of the site
*/
Route::get('/home', 'HomeController@index') -> name('home.index');
Resources routes
The descriptions in the resource type routes are identified by their method in the controller.
/**
* @index Show the main view
* @create Show the view to create a photo
* @store Save a photo in database
* @edit Show the view to edit a photo
* @update Update photo data in database
* @destroy Delete a photo in database
*/
Route::resource('photos', 'PhotoController');
Params
Routes params are defined with @param name Description, you can use @param in resource type routes.
/**
* @description Download photo with the photo id.
* @param id ID of the photo in database
*/
Route::get('/photo/{id}/download', 'PhotoController@download');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With