Commit e548a35c authored by VisentiniEmilien's avatar VisentiniEmilien

refactor projet

parent d86d35c1
.idea/
.project/
tp1/src/sql/games_data.sql
tp1/src/sql/games_schema.sql
tp1/vendor/
\ No newline at end of file
*.idea/
*.project/
*games_data.sql
*games_schema.sql
*vendor/
*conf/
\ No newline at end of file
Killian Schuler, Emilien Visentini, Vincent Kbida, Loïc Tardieu
Killian Schuler, Emilien Visentini, Vincent Kbida, Loïc Tardieu
Ceci est le dépot où sera déposé nos projets
\ No newline at end of file
SELECT name
from game
where name LIKE '%Mario%' OR alias LIKE '%Mario%';
SELECT name
from company
where location_country LIKE '%Japan%';
SELECT name
from platform
where install_base > 10000000;
SELECT name
from game
order by name
limit 21173, 442;
drop procedure if exists page;
delimiter //
CREATE PROCEDURE page (IN p INT)
BEGIN
set p = (p-1)*500;
SELECT id, name
from game
order by id
limit p, 500;
END//
SELECT name
from game
where name LIKE '%Mario%' OR alias LIKE '%Mario%';
SELECT name
from company
where location_country LIKE '%Japan%';
SELECT name
from platform
where install_base > 10000000;
SELECT name
from game
order by name
limit 21173, 442;
drop procedure if exists page;
delimiter //
CREATE PROCEDURE page (IN p INT)
BEGIN
set p = (p-1)*500;
SELECT id, name
from game
order by id
limit p, 500;
END//
call page(2)
\ No newline at end of file
RewriteEngine On
#
# RewriteBase indispensable sur webetu :
# RewriteBase /www/marcolet3u/php-project/
#
# Pour interdire l'accès aux répertoires contenant du code
RewriteRule ^sql(/.|)$ - [NC,F]
RewriteRule ^src(/.|)$ - [NC,F]
RewriteRule ^vendor(/.*|)$ - [NC,F]
#
# réécriture pour slim
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
\ No newline at end of file
{
"name": "slim/slim",
"type": "library",
"description": "Slim Framework, a PHP micro framework",
"keywords": ["microframework","rest","router"],
"homepage": "http://github.com/codeguy/Slim",
"license": "MIT",
"authors": [
{
"name": "Killian Schuler",
"role": "Developer"
},
{
"name": "Emilien Visentini",
"role": "Developer"
},
{
"name": "Vincent Kbida",
"role": "Developer"
},
{
"name": "Loïc Tardieu",
"role": "Developer"
}
],
"require": {
"php": ">=7.0.0",
"illuminate/database": "5.5.*"
},
"suggest": {
"ext-mcrypt": "Required for HTTP cookie encryption",
"phpseclib/mcrypt_compat": "Polyfil for mcrypt extension"
},
"autoload": {
"psr-0": { "Slim": "." }
}
}
{
"require": {
"illuminate/database": "5.5.*",
"slim/slim": "2.*",
"php": ">=7.0"
},
"autoload": {
"psr-4": {
"bdd\\": "./src"
}
}
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "516743bf32429efd7948e30f637f15b7",
"content-hash": "3e70f60fac24a2aa60eedcd9ce200f65",
"packages": [
{
"name": "doctrine/inflector",
......@@ -322,6 +322,51 @@
"description": "Update helper",
"time": "2019-07-29T11:03:54+00:00"
},
{
"name": "myclabs/php-enum",
"version": "1.7.2",
"source": {
"type": "git",
"url": "https://github.com/myclabs/php-enum.git",
"reference": "45f01adf6922df6082bcda36619deb466e826acf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/45f01adf6922df6082bcda36619deb466e826acf",
"reference": "45f01adf6922df6082bcda36619deb466e826acf",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35|^5.7|^6.0",
"squizlabs/php_codesniffer": "1.*"
},
"type": "library",
"autoload": {
"psr-4": {
"MyCLabs\\Enum\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP Enum contributors",
"homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
}
],
"description": "PHP Enum implementation",
"homepage": "http://github.com/myclabs/php-enum",
"keywords": [
"enum"
],
"time": "2019-08-19T13:53:00+00:00"
},
{
"name": "nesbot/carbon",
"version": "1.39.1",
......@@ -480,18 +525,65 @@
],
"time": "2017-10-23T01:57:42+00:00"
},
{
"name": "slim/slim",
"version": "2.6.3",
"source": {
"type": "git",
"url": "https://github.com/slimphp/Slim.git",
"reference": "9224ed81ac1c412881e8d762755e3d76ebf580c0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slimphp/Slim/zipball/9224ed81ac1c412881e8d762755e3d76ebf580c0",
"reference": "9224ed81ac1c412881e8d762755e3d76ebf580c0",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"suggest": {
"ext-mcrypt": "Required for HTTP cookie encryption",
"phpseclib/mcrypt_compat": "Polyfil for mcrypt extension"
},
"type": "library",
"autoload": {
"psr-0": {
"Slim": "."
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Josh Lockhart",
"email": "info@joshlockhart.com",
"homepage": "http://www.joshlockhart.com/"
}
],
"description": "Slim Framework, a PHP micro framework",
"homepage": "http://github.com/codeguy/Slim",
"keywords": [
"microframework",
"rest",
"router"
],
"time": "2017-01-07T12:21:41+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.14.0",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "34094cfa9abe1f0f14f48f490772db7a775559f2"
"reference": "7b4aab9743c30be783b73de055d24a39cf4b954f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/34094cfa9abe1f0f14f48f490772db7a775559f2",
"reference": "34094cfa9abe1f0f14f48f490772db7a775559f2",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f",
"reference": "7b4aab9743c30be783b73de055d24a39cf4b954f",
"shasum": ""
},
"require": {
......@@ -503,7 +595,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.14-dev"
"dev-master": "1.13-dev"
}
},
"autoload": {
......@@ -537,20 +629,20 @@
"portable",
"shim"
],
"time": "2020-01-13T11:15:53+00:00"
"time": "2019-11-27T14:18:11+00:00"
},
{
"name": "symfony/translation",
"version": "v4.4.4",
"version": "v4.4.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "f5d2ac46930238b30a9c2f1b17c905f3697d808c"
"reference": "f7669f48a9633bf8139bc026c755e894b7206677"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/f5d2ac46930238b30a9c2f1b17c905f3697d808c",
"reference": "f5d2ac46930238b30a9c2f1b17c905f3697d808c",
"url": "https://api.github.com/repos/symfony/translation/zipball/f7669f48a9633bf8139bc026c755e894b7206677",
"reference": "f7669f48a9633bf8139bc026c755e894b7206677",
"shasum": ""
},
"require": {
......@@ -613,7 +705,7 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2020-01-15T13:29:06+00:00"
"time": "2019-12-12T12:53:52+00:00"
},
{
"name": "symfony/translation-contracts",
......@@ -680,7 +772,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=7.0.0"
"php": ">=7.0"
},
"platform-dev": []
}
driver=mysql
username=root
host=localhost
database=gamepedia
charset=utf8mb4
collation=utf8mb4_general_ci
\ No newline at end of file
<?php
require_once '../vendor/autoload.php';
use bdd\controleur\ControleurRequete;
use Illuminate\Database\Capsule\Manager as DB;
$db = new DB();
//SI CA NE FONCTIONNE PAS, ENLEVER LES COMMENTAIRES : CES INFOS SONT DEJA DANS LE CONF.INI
//LA LIGNE DU PASSWORD NE DEVRAIT PAS ETRE NECESSAIRE CAR NOUS NOUS CONNECTONS AVEC ROOT, SINON, LA METTRE QUAND MEME
/*$db->addConnection( [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'gamepedia',
'username' => 'user',
//'password' => 'password',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => ''
] );*/
// ajout des informations pour se connecter à la base de données
$ini_file = parse_ini_file('../conf/conf.ini');
$db->addConnection([
'driver' => $ini_file['driver'],
'host' => $ini_file['host'],
'database' => $ini_file['database'],
'username' => $ini_file['username'],
'password' => $ini_file['password'],
'charset' => $ini_file['charset'],
'collation' => $ini_file['charset'] . '_unicode_ci',
'prefix' => ''
]);
$db->setAsGlobal();
$db->bootEloquent();
session_start();
$app = new Slim();
$app->get('/', function () {
$v = new HomeView();
$v->renderHome();
})->name('accueil');
$app->get('/ex1/requete1', function () {
$c = new ControleurRequete();
$c->selectMario();
})->name('ex1 requete 1');
$app->get('/ex1/requete2', function () {
$c = new ControleurRequete();
})->name('ex1 requete 2');
$app->get('/ex1/requete3', function () {
$c = new ControleurRequete();
})->name('ex1 requete 3');
$app->get('/ex1/requete4', function () {
$c = new ControleurRequete();
})->name('ex1 requete 4');
<?php
// Import de la class qui a pour but de charger tous les imports du projet
require_once './vendor/autoload.php';
// Liste des tous les imports
use bdd\controllers\ControleurRequete;
use \bdd\views\AccueilView;
use \Illuminate\Database\Capsule\Manager as DB;
use \Slim\Slim;
// instance de la base de données
$db = new DB();
// ajout des informations pour se connecter à la base de données
$ini_file = parse_ini_file('src/conf/conf.ini');
$db->addConnection([
'driver' => $ini_file['driver'],
'host' => $ini_file['host'],
'database' => $ini_file['database'],
'username' => $ini_file['username'],
'password' => $ini_file['password'],
'charset' => $ini_file['charset'],
'collation' => $ini_file['charset'] . '_unicode_ci',
'prefix' => ''
]);
// demarage de la basse de donnée
$db->setAsGlobal();
$db->bootEloquent();
// demerage d'un session
session_start();
// intance de slim qui a pour but de créer le rootage des urls
$app = new Slim();
/*-----|accueil|-----*/
$app->get('/', function () {
$v = new AccueilView();
$v->render();
})->name('accueil');
$app->get('/mario', function () {
$v = new ControleurRequete();
$v->selectMario();
})->name('mario');
$app->get('/japan', function () {
$v = new ControleurRequete();
$v->selectJapanCompany();
})->name('japan');
$app->get('/platformBase', function () {
$v = new ControleurRequete();
$v->selectPlatformBase();
})->name('platformBase');
$app->get('/gameNumber', function () {
$v = new ControleurRequete();
$v->selectGameNumber();
})->name('gameNumber');
$app->get('/page/:p', function ($p) {
$v = new ControleurRequete();
$v->selectPage($p);
})->name('page');
$app->run();
\ No newline at end of file
<?php
namespace bdd\controleur;
use bdd\models\company;
use bdd\models\game;
use bdd\models\platform;
class ControleurRequete{
public function selectMario(){
$jeu = \bdd\models\game::select('name')->where('name','like','%Mario%','or','alias','like','%Mario%')->get();
$vue = new \bdd\vue\RequeteVue($jeu);
$html = $vue->render(1);
$rs->getBody()->write($html);
return $rs;
}
public function selectCompanyCountry(){
$company = \bdd\models\company::select('name')->where('location_country','like','%Japan%')->get();
$vue = new \bdd\vue\RequeteVue($company);
$html = $vue->render(1);
$rs->getBody()->write($html);
return $rs;
}
public function selectPlatformBase(){
$platform = \bdd\models\platform::select('name')->where('install_base','>','10000000')->get();
$vue = new \bdd\vue\RequeteVue($platform);
$html = $vue->render(1);
$rs->getBody()->write($html);
return $rs;
}
public function selectGameNumber(){
$game = \bdd\models\game::select('name')->orderBy('name')->limit('21173','422')->get();
$vue = new \bdd\vue\RequeteVue($game);
$html = $vue->render(1);
$rs->getBody()->write($html);
return $rs;
}
public function selectPage($p){
$p = ($p-1)*500;
$jeu = \bdd\models\game::select('id','name')->orderBy('id')->limit($p,'500')->get();
$vue = new \bdd\vue\RequeteVue($jeu);
$html = $vue->render(1);
$rs->getBody()->write($html);
return $rs;
}
<?php
namespace bdd\controllers;
use bdd\models\company;
use bdd\models\game;
use bdd\models\platform;
class ControleurRequete{
public function selectMario(){
$jeu = \bdd\models\game::select('name')->where('name','like','%Mario%','or','alias','like','%Mario%')->get();
$vue = new \bdd\views\RequeteView($jeu);
$vue->render(1);
}
public function selectJapanCompany(){
$company = \bdd\models\company::select('name')->where('location_country','like','%Japan%')->get();
$vue = new \bdd\views\RequeteView($company);
$vue->render(1);
}
public function selectPlatformBase(){
$platform = \bdd\models\platform::select('name')->where('install_base','>','10000000')->get();
$vue = new \bdd\views\RequeteView($platform);
$vue->render(1);
}
public function selectGameNumber(){
$game = \bdd\models\game::select('name')->orderBy('name')->take(442)->skip(21173)->get();
$vue = new \bdd\views\RequeteView($game);
$vue->render(1);
}
public function selectPage($p){
$p = ($p-1)*500;
$jeu = \bdd\models\game::select('id','name')->orderBy('id')->take(500)->skip($p)->get();
$vue = new \bdd\views\RequeteView($jeu);
$vue->render(1);
}
}
\ No newline at end of file
<?php
namespace bdd\models;
class Company extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'company';
protected $primaryKey = 'id';
public $timestamps = false;
public function platform(){
return $this->belongsTo('bdd\models\company', 'id');
}
<?php
namespace bdd\models;
class Company extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'company';
protected $primaryKey = 'id';
public $timestamps = false;
public function platform(){
return $this->belongsTo('bdd\models\company', 'id');
}
}
\ No newline at end of file
<?php
namespace bdd\models;
class Game extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'game';
protected $primaryKey = 'id';
public $timestamps = false;
public function platform(){
return $this->belongsTo('bdd\models\game', 'id');
}
<?php
namespace bdd\models;
class Game extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'game';
protected $primaryKey = 'id';
public $timestamps = false;
public function platform(){
return $this->belongsTo('bdd\models\game', 'id');
}
}
\ No newline at end of file
<?php
namespace bdd\models;
class Platform extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'platform';
protected $primaryKey = 'id';
public $timestamps = false;
public function platform(){
return $this->belongsTo('bdd\models\platform', 'id');