We will use PHPDox and JSDoc for this example, but feel free to explore your options and follow the installation and tutorials from the tool’s Github pages.
Please notice that all the automatic documentation from the tools are based on your code documentation. If you documented (commented) well enough your code, the documentation can be automated. Follow the standards in code documentation
so the tools know how to parse your code.
For example for the function login, use the comment to give a description of what the function do. Use the keyword “@param” to define which parameters are used and “@return” for the description of what the function returns (if applicable).
For each parameter include the type as well.
* Login via email and password
* @param Request $request Request
* @return Response
* @throws BadRequestHttpException
* @throws UnauthorizedHttpException
public function login(Request $request
Installation and execution
You can install this tool via composer:
composer require --dev theseer/phpdox
Then use the command line:
As of version 0.4 phpDox requires an xml configuration file. In case a project you want to generate documentation for does not come with one, you can create it by calling
vendor/bin/phpdox --skel > phpdox.xml.dist
Create the documentation using the following command:
This will create the folder docs. Inside the folder, you will find the htmlx Documentation.
Sample of the result for classes: