Download the PHP package ronanflavio/laradocs-generate without Composer
On this page you can find all versions of the php package ronanflavio/laradocs-generate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ronanflavio/laradocs-generate
More information about ronanflavio/laradocs-generate
Files in ronanflavio/laradocs-generate
Package laradocs-generate
Short Description A package to create a simple API docs from your Laravel application
License MIT
Informations about the package laradocs-generate
Live preview
Click here to check the output result.
Installation
PHP 7.2 and Laravel 6.x or higher are required.
After updating composer, add the service provider to the providers
array in config/app.php
Generating docs
To generate docs simply run the command:
This command will create the routes.json
file into your resource
folder. The file will be used to provide data to render the view.
You may want to ignore the routes.json
file into your .gitignore
.
Access your app host with /docs
URI to see the docs page:
E.g.: http://127.0.0.1:8000/docs
Writing docs
Tha main goal of this package is to indicate which specifically is the URI parameters, the request body parameters and what is coming within the response.
To achieve this, you may want to write some custom PHPDocs above your controller class, actions and your DTOs' properties. Let's see some practical examples:
Typing the request and response objects
To indicate which is the URI parameter type, use the default @param
annotation.
To indicate which class object must be given within the request, you must write the full qualified name of it's class within the @request
annotation.
To indicate which class object will be returned, you must write the full qualified name of it's class within the @response
annotation. If there is no class object to be returned, just type the the variable type (e.g.: boolean
, int
etc...) instead. void
will be provided if there is no @response
.
Typing the DTOs' attributes specifications
To indicate which is the variable type from an attribute you may use the standard @var
annotation. If you want to be more specific, you can also indicate a practical example to that attribute using the @example
annotation. See some code bellow:
Publishing
Publish the config file by running:
This will create the docs.php
file in your config
directory.
You can also publish the view blade file by running:
This will create the docs.blade.php
file in your resource/views
directory.
License
The Laradocs Generate is free software licensed under the MIT license.