Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create the documentation of laravel project?

Tags:

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?

like image 553
korg Avatar asked Mar 29 '18 18:03

korg


People also ask

What does Laravel use for 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 .

How do I create API document in Laravel?

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.


1 Answers

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');
like image 185
Luis Alcaras Avatar answered Sep 23 '22 13:09

Luis Alcaras