コード例 #1
0
ファイル: app.php プロジェクト: alidzapp/MicroFramework-PHP
use Model\Finder\UserFinder;
use Http\JsonResponse;
use Http\Response;
use Http\Request;
use Model\DataBase\DatabaseConnection;
use Model\DataMapper\StatusMapper;
use Model\DataMapper\UserMapper;
use Model\Entity\Status;
use Model\Entity\User;
// Config
$debug = true;
$connection = new DatabaseConnection();
$statusFinder = new StatusFinder($connection);
$userFinder = new UserFinder($connection);
$statusMapper = new StatusMapper($connection);
$userMapper = new UserMapper($connection);
//$finder = new JsonFinder();
/**
 * Index
 */
$app = new \App(new View\TemplateEngine(__DIR__ . '/templates/'), $debug);
// Matches if the HTTP method is GET -> /
$app->get('/', function () use($app) {
    $app->redirect('/statuses');
});
// Matches if the HTTP method is GET -> /statuses/
$app->get('/statuses/', function () use($app) {
    $app->redirect('/statuses');
});
// Matches if the HTTP method is GET -> /login
$app->get('/login', function () use($app) {
コード例 #2
0
ファイル: app.php プロジェクト: PierreCharles/uFramework-PHP
$login = '******';
$mdp = 'p4ssw0rd';
$host = '127.0.0.1';
/**
 * Connection
 */
$connection = null;
try {
    $connection = new DatabaseConnection('mysql:host=' . $host . ';dbname=' . $base, $login, $mdp);
} catch (PDOException $e) {
    echo 'Connection failed : ' . $e->getMessage();
}
$statusFinder = new StatusFinder($connection);
$userFinder = new UserFinder($connection);
$statusMapper = new StatusMapper($connection);
$userMapper = new UserMapper($connection);
/**
 * Index
 */
$app = new \App(new View\TemplateEngine(__DIR__ . '/templates/'), $debug);
// Matches if the HTTP method is GET -> /
$app->get('/', function () use($app) {
    $app->redirect('/statuses');
});
// Matches if the HTTP method is GET -> /statuses/
$app->get('/statuses/', function () use($app) {
    $app->redirect('/statuses');
});
// Matches if the HTTP method is GET -> /login
$app->get('/login', function () use($app) {
    if (isset($_SESSION['is_connected']) && $_SESSION['is_connected']) {