A sample way to generate Swagger documentation for your RESTful API using doctrine annotations.
- Compatible with the Swagger 2.0 specification
- Support multi-apps
Installation (with Composer)
- Clone the code
- Install vendors
composer install
- Configure the host like this
vi /etc/hosts
# add IP VHOST
127.0.0.1 apidoc.local
- Configure the virtual host for Apache
<VirtualHost *:80>
ServerName apidoc.local
DocumentRoot "/www/apidoc/public"
<Directory "/www/apidoc/public">
# use mod_rewrite for pretty URL support
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# use index.php as index file
DirectoryIndex index.html index.php
</Directory>
</VirtualHost>
Add annotations to your php files.
/**
* @SWG\Info(title="My First API", version="0.1")
*/
/**
* @SWG\Get(
* path="/api/resource.json",
* @SWG\Response(response="200", description="An example resource")
* )
*/
See the Examples directory for more.
- Open config/app.php
- To Config the "app-list"
- browse http://YOUR_HOST/APP_NAME, for example: http://apidoc.local/apiv1 http://apidoc.local/apiv2
- http://swagger.io/
- https://github.com/swagger-api/swagger-spec/
- http://bfanger.github.io/swagger-explained/
Feel free to submit Github Issues or pull requests.