Laravel project Swagger
An example of Swagger on Laravel 4.2 Generate interactive OpenAPI documentation for your RESTful API using doctrine annotations.
Source:
Summary
Here are the steps you can expect to follow in order to install swagger to your PHP server code.
- Download Swagger-Php Using Composer
- Add Annotations to Generate Documentation
- Generate Swagger JSON File
- Download Swagger-UI Package to your Project
- Connect Swagger-UI To Your Code
Tech
This project uses a number of open source projects to work properly:
- Docker - Docker is a tool designed to make it easier to create, deploy, and run applications by using containers.
- Docker Compose - Compose is a tool for defining and running multi-container Docker applications.
- Laravel 4.2 - PHP framework.
- Composer PHP - A Dependency Manager for PHP.
- Swagger-PHP - Generate interactive OpenAPI documentation for your RESTful API using doctrine annotations.
Installation
This project requires Docker to run.
Clone project from Github:
$ git clone https://github.com/henrycv/laravel-4.2-swagger-ui.git
$ cd laravel-4.2-swagger-ui
Start the Docker container
$ docker-compose up
Enter to the PHP container
$ docker exec -it swagger-php5 sh
Scan and reload the Swagger JSON file. Excluding vendor/zircode/Examples, which requests to http://petstore.swagger.io
$ ./vendor/zircote/swagger-php/bin/swagger --exclude zircote -o public/swagger-ui/swagger.json
Navigate to http://localhost/api/v2/doc on you local environment.
Todos
- Add Authentication and Authorization
- Write Tests
- Add documentation
License
MIT
Free Software, Hell Yeah!