Git Product home page Git Product logo

pokedex's Introduction

Pokedex

Ce projet est un TP de l'esiee d'Amiens

pokemon

pokemon

Script d'installation

Pour installer le projet vous pouvez suivre les étapes classique ou lancer ce script d'installation

curl https://git.arkalo.ovh/Omer/project/raw/branch/master/install.sh | bash

Installation

apt install nginx git php-fpm php-zip php-xml

Vous pouvez aussi installer apache au lieu de nginx

Ce projet fonctionne sous symfony 5 Il est donc necessaire d'installer la version > 7.3 de PHP.

cd /var/www/html
git clone 
chown -R www-data:www-data webapp

Environement

cp .env.dist .env

Editez le fichier .env avec vos infos d'environements (database, constantes...)

Database

N'oubliez pas de remplir le fichier d'environment avant de procéder à cette étape

php bin/console d:d:c

Appliquer les migrations

php bin/console m:migration
php bin/console d:m:m

Webserver

Nginx

server {
    root /var/www/html/webapp/public;

    client_max_body_size 10G;
    fastcgi_buffers 64 4K;

    location / {
        proxy_read_timeout 180000;
         proxy_connect_timeout 180000;
         proxy_send_timeout 180000;
         send_timeout 180000;
        # try to serve file directly, fallback to app.php
        try_files $uri /index.php$is_args$args;
    }
    # DEV
    # This rule should only be placed on your development environment
    # In production, don't include this and don't deploy index_dev.php or config.php
    location ~ ^/(index_dev|config)\.php(/|$) {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        # Caveat: When PHP-FPM is hosted on a different machine from nginx
        #         $realpath_root may not resolve as you expect! In this case try using
        #         $document_root instead.
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
    }
    # PROD
    location ~ ^/index\.php(/|$) {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
       # When you are using symlinks to link the document root to the
       # current version of your application, you should pass the real
       # application path instead of the path to the symlink to PHP
       # FPM.
       # Otherwise, PHP's OPcache may not properly detect changes to
       # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
       # for more information).
       fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
       fastcgi_param DOCUMENT_ROOT $realpath_root;
       # Prevents URIs that include the webapp controller. This will 404:
       # http://domain.tld/app.php/some-path
       # Remove the internal directive to allow URIs like this
       internal;
   }

   # return 404 for all other php files not matching the webapp controller
   # this prevents access to other php files you don't want to be accessible.
   location ~ \.php$ {
     return 404;
   }

   error_log /var/log/nginx/project_error.log;
   access_log /var/log/nginx/project_access.log;
}

Ces deux lignes servent à augmenter la taille upload sur le serveur. J'ai mis 1G pour uploader les images (c'est laaaaaargement bon)

client_max_body_size 1G;
fastcgi_buffers 64 4K;

Apache

Vous pouvez aussi installer ce projet avec apache

<VirtualHost *:80>
    ServerName domain.tld
    ServerAlias www.domain.tld

    DocumentRoot /var/www/project/public
    DirectoryIndex /index.php

    <Directory /var/www/project/public>
        AllowOverride None
        Order Allow,Deny
        Allow from All

        FallbackResource /index.php
    </Directory>

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeeScript assets
    # <Directory /var/www/project>
    #     Options FollowSymlinks
    # </Directory>

    # optionally disable the fallback resource for the asset directories
    # which will allow Apache to return a 404 error when files are
    # not found instead of passing the request to Symfony
    <Directory /var/www/project/public/bundles>
        DirectoryIndex disabled
        FallbackResource disabled
    </Directory>
    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined

    # optionally set the value of the environment variables used in the application
    #SetEnv APP_ENV prod
    #SetEnv APP_SECRET <app-secret-id>
    #SetEnv DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name"
</VirtualHost>

API (jwt)

Sur ce projet j'ai rajouté une API qui permet de récupérer via des requetes GET.

curl http://localhost/pokemon.json
[
  {
    "id": 4512,
    "numero": 1,
    "nom": "Bulbasaur",
    "vie": 45,
    "attaque": 49,
    "defense": 49,
    "legendaire": false,
    "type1": "\/api\/types\/1678",
    "type2": "\/api\/types\/1690",
    "generation": {
      "id": 817,
      "name": "1"
    }
  },
  {
    "id": 4513,
    "numero": 2,
    "nom": "Ivysaur",
    "vie": 60,
    "attaque": 62,
    "defense": 63,
    "legendaire": false,
    "type1": "\/api\/types\/1678",
    "type2": "\/api\/types\/1677",
    "generation": {
      "id": 817,
      "name": "1"
    }
  },
]

Import pokemon

Pour importer les pokemons, tapez cette commande à la racine du projet

php bin/console import:pokemon 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.