Web applications allowing the management of stocks of several stores. Several roles are available:
- Administrator (management of all stores)
- Store manager (product and seller management for his store)
- Seller (management of the quantity of stock in his store)
The front application is available here.
- Clone
git clone https://github.com/louisthomaspro/triathlon-api
cd triathlon-api
- Run docker-compose
docker-compose up -d
- Load fixtures (mockdata)
docker-compose exec php bin/console hautelook:fixtures:load --purge-with-truncate -n --no-bundles
-
Find the API Swagger documentation at : https://localhost:8443/api/v1/docs
-
GĂ©nerate a token
curl -X POST \
https://localhost:8443/api/v1/login \
-k \
-H 'Content-Type: application/json' \
-H 'Host: localhost:8443' \
-H 'cache-control: no-cache' \
-d '{"email":"louisthomas.pro@gmail.com","password":"coucou"}'
- You can test with multiple roles accounts (password always "coucou")
- Admin (email: louisthomas.pro@gmail.com)
- Store manager (email: user2@gmail.com)
- Seller (email: user3@gmail.com)
- For a better experience, install Triathlon-front
Recreate the database
docker-compose exec php bin/console --env=prod doctrine:schema:drop --full-database --force && docker-compose exec php bin/console doctrine:schema:update --force
Update the database
docker-compose exec php bin/console doctrine:schema:update --force
Create/update an entity
docker-compose exec php bin/console make:entity --api-resource
Problem of rigths ?
sudo chown -R $(whoami) triathlon-api/
Clear you repo
git rm --cached .-r
Generate manually the JWT files
docker-compose exec php sh -c '
set -e
apk add openssl
mkdir -p config/jwt
jwt_passhrase=$(grep ''^JWT_PASSPHRASE='' .env | cut -f 2 -d ''='')
echo "$jwt_passhrase" | openssl genpkey -out config/jwt/private.pem -pass stdin -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
echo "$jwt_passhrase" | openssl pkey -in config/jwt/private.pem -passin stdin -out config/jwt/public.pem -pubout
setfacl -R -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
setfacl -dR -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt
'
When deplying on a server (say yeeees)
composer require symfony/apache-pack
You have to install Heroku CLI for the next commands
Heroku without CI/CD (in 'api' folder)
heroku run bash -a triathlon-api
php bin/console doctrine:schema:create
heroku config:set APP_ENV=prod
git add --all
git commit -a -m "My first API Platform app running on Heroku!"
heroku git:remote -a triathlon-api
git push heroku master
Heroku github login
heroku auth:token
username: blank
password: token
- Make a backup
docker-compose exec db pg_dump -U api-platform api --no-owner --no-acl -f backup.sql
- Copie the sql file generated to local
docker cp CONTAINER_ID:/backup.sql ./backup.sql
- Load the sql file to the server
heroku pg:psql --app triathlon-api < ./backup.sql