Création d'une API Pokédex avec Symfony
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
art.dambrine a61924b960 tweak login form 4 years ago
.idea [partial] implementing liip imagine and autoresize on upload subscriber 4 years ago
bin init commit 4 years ago
config users and auth 4 years ago
migrations users and auth 4 years ago
public [partial] implementing liip imagine and autoresize on upload subscriber 4 years ago
sql import cmd pokedex:setup 4 years ago
src users and auth 4 years ago
templates tweak login form 4 years ago
tests init commit 4 years ago
translations init commit 4 years ago
.env basic api crud ok 4 years ago
.env.test init commit 4 years ago
.gitignore [partial] implementing liip imagine and autoresize on upload subscriber 4 years ago
composer.json [partial] implementing liip imagine and autoresize on upload subscriber 4 years ago
composer.lock [partial] implementing liip imagine and autoresize on upload subscriber 4 years ago
phpunit.xml.dist init commit 4 years ago
readme.md Mise à jour de 'readme.md' 4 years ago
symfony.lock [partial] implementing liip imagine and autoresize on upload subscriber 4 years ago

readme.md

Projet symfony - pokedex

Dans le cadre du cours de developpement web avancé nous avons fait le choix de developper un pokedex via le framework PHP Symfony. Le pokedex sera accessible en direct depuis le site web ou via une api exposée via le bundle api-platform.

Deploiement simplifié du projet

Prérequis :

  • docker

Etape 1 : télécharger le projet d'initialisation de symfony

git clone https://gitea.art-dambrine.ovh/art.dambrine/symfony-docker-init.git projet-pokedex

Si vous ne souhaitez pas déployer la base de données via docker en local commentez les lignes correpsondantes du docker-compose.yml.

NOTE : pensez à modifier le port d'exposition nginx '80:80' par '<PORT_EXPOSITION>:80'

version: '3.8'
 services:
   # mariadb:
   #   image: mariadb
   #   restart: on-failure
   #   volumes: 
   #     - database_pokedex:/var/lib/mysql
   #   ports:
   #     - '3306:3306'
   #   environment:
   #     MYSQL_ROOT_PASSWORD: root_password    
   #     MYSQL_USER: my_user
   #     MYSQL_PASSWORD: my_password
   #     MYSQL_DATABASE: my_pokedex
   nginx:
     image: nginx:1.19-alpine
     restart: on-failure
     volumes:
       - './docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro'
     ports:
       - '80:80'
     depends_on:
       - php
     volumes_from:
       - php
   php:
     build:
       context: .
       dockerfile: docker/php/Dockerfile
     restart: on-failure
     volumes:
       - '.:/usr/src/app'
     user: "${UID}:${GID}"
 # volumes: 
 #   database_pokedex:

Etape 2 : télécharger les sources du projet pokedex

cd projet-pokedex
git clone https://gitea.art-dambrine.ovh/art.dambrine/pokedex-api.git src

Etape 3 : lancer la stack docker

#dans le dossier racine projet-pokedex
docker-compose build
UID=${UID} GID=${GID} docker-compose up -d  #on passe au docker-compose notre UID et GID pour avoir les droits d'édition partagé entre hôte et container sur les fichiers

Etape 4 : installez le projet symfony et la base de données

  1. Modifier les accès à la base de données
cd src  #se placer dans le dossier du projet symfony
cp .env .env.local  #dupliquer le .env en .env.local

Editer le fichier .env.local pour correspondre avec votre base (exemple ici pour la base locale docker)

#.env.local
DATABASE_URL="mysql://my_user:my_password@mariadb:3306/my_pokedex"
  1. Installer les dépendances de symfony
docker-compose exec php bash  #connexion au shell du container php
cd src  #se placer dans le dossier symfony
composer install
  1. Mettre en place la base de données pokedex via la commande symfony custom
php bin/console d:m:m  #mise en place du schéma de la bdd
php bin/console pokedex:setup  #command custom charge les données dans le dossier /sql