https://github.com/sci3ma/sf4-api-versioning
Example of API versioning in Symfony Framework v4
https://github.com/sci3ma/sf4-api-versioning
Last synced: about 1 year ago
JSON representation
Example of API versioning in Symfony Framework v4
- Host: GitHub
- URL: https://github.com/sci3ma/sf4-api-versioning
- Owner: sci3ma
- Created: 2019-03-14T16:17:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-15T07:27:25.000Z (about 7 years ago)
- Last Synced: 2025-02-02T09:46:05.821Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
sf4-api-versioning
=================================================
Example of API versioning on Symfony Framework v4
Used additional bundles
-------------
* friendsofsymfony/rest-bundle
* jms/serializer-bundle
* sci3ma/sf4grumphp (optional)
Steps to create project
------------------
1. Create `Resource/config/api_routing.yaml` for controllers routes
1. Include `Resource/config/api_routing.yaml` into `config/routes.yaml`
1. Add proper prefix with `version` parameter
1. Add available/supported versions in `.env` file
1. Create Entity with properties:
1. id
1. name
1. age
1. color
1. Create Controller and define RESTful actions
Run project
-----------
1. Run build-in php server `bin/console server:start`
1. Go to:
1. `[GET] 127.0.0.1:8000/api/v1.1/godzillas/1` and see response with properties:
1. id
1. name
1. age
1. `[GET] 127.0.0.1:8000/api/v1.2/godzillas/1` and see response with properties:
1. id
1. name
1. age
1. color
1. `[GET] 127.0.0.1:8000/api/v1.3/godzillas/1` and see response with properties:
1. id
1. name
1. age
1. full_name - which is virtual property
1. Similarly as example above:
1. `[GET] http://127.0.0.1:8000/api/v1.1/godzillas`
1. `[GET] http://127.0.0.1:8000/api/v1.2/godzillas`
1. `[GET] http://127.0.0.1:8000/api/v1.3/godzillas`
Conclusion
----------
The main goal of versioning api is changing/updating response structure with keeping the older version in the same time.