Create your Symfony 4 RESTful API with JWT Authentication simply and fastly. SF4 RESTful API Skeleton with Docker and JWT Auth.
MIT License
This project is all you need to start simply and fastly your new RESTful APIs using Symfony 4. This stack uses Docker and Makefile to create an easy maintenance cycle for your REST API.
git clone https://github.com/Maykonn/docker-symfony-4-restful.git
hosts
file and add app.localhost
:127.0.0.1 app.localhost
make install
make database
make database-structure
make start
The initial RESTful API code provided by this bundle is an example of a JWT Authentication approach with Symfony 4, below are listed all initial routes provided:
POST > http://app.localhost:8080/register
(json body example):
{
"username": "my-username",
"password": "123456"
}
POST > http://app.localhost:8080/login_check
(json body example):
{
"username": "my-username",
"password": "123456"
}
GET > http://app.localhost:8080/api
(Authorization Header is required for all protected routes):
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ik1heWtvbm4iLCJpYXQiOjE1MTYyMzkwMjJ9.b7rMHdFlAixTQA6DzLoHIjw3MrRtkbm3tuUr_zgXhmE
A pretty basic API is provided by this project and now you can start creating your own resources to your API with new controllers, models, repositories, services, whatever you need.
The Makefile is here to keep the management of your API as simple as possible avoiding confuse commands.
make install
: to install and build the projectmake update
: to update the project dependenciesmake start
: to start the APImake stop
: to stop the APImake restart
: to stop and then start again the APImake jwt-keys
: to create the public and private keys to protect your routes with JWT, the make install
uses this commandmake database
: to create the databasemake database-structure
: to create the database structure (tables, etc.)make database-structure-update
: to update the database structureRead more about make
here: https://www.gnu.org/software/make/
OBS: make database*
commands will be executed only when in "dev" environment.
If are you aware about the risks use the force=1
param, example:
make database-structure-update force=1
If you need help with this bundle please consider open a question on StackOverflow
using the docker-symfony-4-restful
tag, it is the official support platform for this bundle.
Github Issues are dedicated to bug reports and feature requests.
You can contribute to this project cloning this repository in your clone you just need to create a new branch using a name related to the new functionality which you'll create. When you finish your work, you just need to create a pull request which will be revised, merged to master branch (if the code doesn't break the project) and published as a new release.