Skip to content
Snippets Groups Projects
index.php 1.13 KiB
<?php
require_once __DIR__ . '/vendor/autoload.php';
session_start();
use \Slim\Slim as Slim;
use Illuminate\Database\Capsule\Manager as DB;
use \gp\controleurs\ControleurPrincipal as ControleurPrincipal;
use \gp\controleurs\ControleurGame as ControleurGame;
use \gp\controleurs\ControleurScript as ControleurScript;

$db = new DB();
$db->addConnection(parse_ini_file('./conf/conf.ini'));

$db->setAsGlobal();
$db->bootEloquent();

$app = new \Slim\Slim();
$app->response->headers->set('Content-Type', 'application/json');

$app->get('/',function () use ($app) {
    $c = new ControleurPrincipal();
    $c->afficherAccueil();
    $app->response->headers->set('Content-Type', 'text/html');
});

// Affiche un jeu au fromat JSON
$app->get('/api/games/:id',function ($id) {
    $c = new ControleurGame();
    $c->getGame($id);
});
// Affiche tous les jeu paginé au format JSON
$app->get('/api/games/',function () {
    $c = new ControleurGame();
    $c->getGames();
})->name('getGame');
// Affiche les commentaires d'un jeu
$app->get('/api/games/:id/comments',function ($id) {
    $c = new ControleurGame();
    $c->getGameComments($id);
});
$app->run();