Home >Backend Development >PHP Tutorial >Use of ApiDoc
This article introduces you to the use of ApiDoc. Friends who are interested can take a look.
apiDoc creates a documentation from API annotations in your source code
apiDoc is an interface document. Its creation method is based on Interface comments for your source code. We only need to write the corresponding documentation for the interface, and then use the apiDoc generation interface documentation tool to generate the documentation for easy management and viewing.
1. Install apidoc (what is npm??? Ask your front-end classmates yourself...)
npm install apidoc -g
Install http-server
npm install http-server -g
2. Add documentation (official example) to the interface and add it in front of the Controller entry method.
/** * @api {get} /user/:id Request User information * @apiName GetUser * @apiGroup User * * @apiParam {Number} id Users unique ID. * * @apiSuccess {String} firstname Firstname of the User. * @apiSuccess {String} lastname Lastname of the User. */
3. Create apidoc.json (official example)
{ "name": "example", "version": "0.1.0", "description": "apiDoc basic example", "apidoc": { "title": "Custom apiDoc browser title", "url" : "https://api.github.com/v1" } }
4. Generate apiDoc
apidoc -i app/Http/Controllers -o apidoc/
5. Run
http-server api/doc
The above is the detailed content of Use of ApiDoc. For more information, please follow other related articles on the PHP Chinese website!