Welcome to the Symfony Project for PHP Challenge.
For details on how to download and get started with Symfony, see the Installation chapter of the Symfony Documentation.
Clone the project
Repository: PHP-CHALLENGE
Symfony
- 4.4
For Docker
JWT authentication
- OpenSSL library
If you are not going to use Docker
- composer
- php-7.4
- mysql
| - PHP 7.4 |
| - MYSQL 8.0.19 |
| - GIT | - COMPOSER |
| - DOCKER | - DOCKER-COMPOSE |
| DDD | CLEAN CODE |
Edit hosts:
$ sudo vim /etc/hosts
127.0.0.1 dev.service.com mysql
Composer command:
composer install
Create the database and tables:
sql-files/api-service.sql
docker-compose up -d
To authenticate you'll need do generate SSH KEYS:
$ mkdir config/jwt
$ openssl genrsa -out config/jwt/private.pem -aes256 4096
$ openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pemConfigure your .env with the ssh pass phrase under JWT_PASSPHRASE:
JWT_PASSPHRASE: '' # ssh key passSend a post to /api/register with the username and password, as follow:
$ curl -X POST http://localhost:8000/register -d _username=guest -d _password=12345
-> User Guest successfully createdThe post will return a Token. With this token you'll be able to access the api resources.
New Token
$ curl -X POST -H "Content-Type: application/json" http://localhost:8000/login_check -d '{"username":"guest","password":"12345"}'
-> { "token": "[TOKEN]" }https://github.com/nelmio/NelmioApiDocBundle