As a background developer, always avoid to the app to write API interface documents, previously used HTML5 and Css3+jqury to write dynamic pages, but each time the change is cumbersome, and it is possible to change the code forgot to modify the document, so on the Internet to find some information, found swagger UI This framework everyone is more recommended, now record the setting of the environment.
The swagger UI is also based on Html+javascript implementations, and enables the ability of online testing to allow developers and testers to test and view the result information of interface calls.
Install the swagger UI in the Ubuntu14.04 and thinkphp frameworks:
1. $ cd/var/www/api
2. Install composer
$ apt-get Update
$ curl-ss https://getcomposer.org/installer | php
$/usr/bin/php composer.phar--version
$ sudo mv Composer.phar/usr/local/bin/composer
$ composer-version
appears with the following information to prove the installation was successful
3. Install swagger-php
$ composer require zircote/swagger-php
$ composer global require zircote/swagger-php
At this time in the API folder will generate a vendor folder, said the installation successfully downloaded Swagger UI file: Https://github.com/swagger-api/swagger-ui download successfully can be placed into the custom directory, Note The directory can access the
Modify the Index.html page in the Dist directory
To modify the generated JSON file path, don't worry. Here's how to generate the JSON file. I am in the API folder, the new Swagger-docs folder, and then run the command
$ php/var/www/api/vendor/zircote/swagger-php/bin/swagger/var/www/api/vendor/zircote/swagger-php/examples-o/var/ Www/api/swagger-docs/swagger.json
Access to the dist file below index.html OK
For information about how the JSON file is generated, refer to the file below the examples folder.