Disclaimer Ce site a été réalisé à des fins pédagogiques dans le cadre du cursus Bachelor de l’école HETIC. Les contenus présentés n'ont pas fait l'objet d'une demande de droit d'utilisation. Ce site ne sera en aucun cas exploité à des fins commerciales.
Visit the documentation at route: /swagger/index.html
.
After cloning the project, go to the root of the project and create a .env.local
file:
touch .env.local
In .env.local
add these lines and make changes according to your configuration:
APP_ENV=dev
DATABASE_URL=mysql://db_user:[email protected]:3306/agoraDb?serverVersion=5.7
CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
Then, install dependencies:
composer install
make install
Create the Database:
./bin/console doctrine:database:create
make db-create
Execute the last migration:
./bin/console doctrine:migration:migrate
make db-migration
Populate database with fixtures:
./bin/console doctrine:fixtures:load
make db-fixture
Launch the server:
symfony server:start
make start
Stop the server:
make stop
First create the JWT Folder in config folder:
mkdir -p config/jwt
Then, generate your .pem
keys according to your JWT_PASSPHRASE
located in .env
, ie, when you will have to enter the passphrase
enter the same value as the JWT_PASSPHRASE
:
openssl genrsa -out config/jwt/private.pem -aes256 4096
Same for this command:
openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem
Now, if you try to login as an existing user like so:
http POST localhost:8000/api/login_check [email protected] password=test
curl -X POST -H "Content-Type: application/json" localhost:8000/api/login_check -d '{"username": "[email protected]", "password": "test"}'
You will retrieve the JWT Token:
{
"token": "eyJ0eXAi..."
}
With this JWT Token, you can now make request on routes /api
of the application. You need to put the token in your Headers
every time you want to make a request.
http --auth-type=jwt --auth="eyJ0eXAi..." localhost:8000/api/users
curl -X GET localhost:8000/api/users -H "Authorization: BEARER eyJ0eXAi..."
Your JWT Token is set to expire at a certain time that is set in config/packages/lexik_jwt_authentication.yaml
:
# Unit is in second. So 900 seconds.
token_ttl: 900
If your JWT Token expire, you will need to re-generate a new one with the second token provided when you login, called refresh_token
, the refresh_token
can only be used once, but everytime you request a new JWT Token you will get a new refresh_token
as well:
{
"refresh_token": "b1ca3f...",
"token": "eyJ0eXAi..."
}
Retrieve a new valid JWT Token:
http POST localhost:8000/api/token/refresh refresh_token=b1ca3f...
curl -X POST -H "Content-Type: application/json" localhost:8000/api/token/refresh -d '{"refresh_token": "b1ca3f..."}'
With this new token, you will be able to fetch data from the API again.
Run:
crontab -e
add the following line, change <PATH_TO_PROJECT>
to your Project PATH
:
0 0 * * * cd ~/<PATH_TO_PROJECT>/agora-api && ./bash_scripts/launch-schedule.sh >> /dev/null 2>&1
Open folder containing cron
binary file:
open /usr/sbin
-
Go to your System Settings > Security & Privacy > Disk access
-
Click on the lock at the bottom left corner and enter your password
-
Drag and drop the
cron
binary file into your System Settings Window. -
Cross the checkbox next to it.
Then it should fix the permission problem.
Prefix the following names with make
:
NAME | DESCRIPTION |
---|---|
start | Start the server |
stop | Stop the server |
cc | Clear the cache |
router | List all routes |
log | Display server logs |
test | Run all tests |
test-file | Run a specific test file that user enter. Example: UserTest |
install | Install dependencies |
db-create | Create the database |
db-migration | Launch migrations |
db-fixture | Load fixtures |
db-update | Run db-migration and db-fixture |
swagger | Update swagger documentation |