示例#1
0
<?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$request = Request::createFromGlobals();
echo "uri=" . ($uri = $request->getPathInfo());
if ($uri == '/') {
    $postController = new PostController();
    $response = $postController->list_action();
} elseif ($uri == '/post') {
    $postController = new PostController();
    $response = $postController->list_action();
} elseif ($uri == '/user') {
    $userController = new UserController();
    $response = $userController->list_action();
} elseif ($uri == '/showpost' && $request->query->has('id')) {
    $postController = new PostController();
    $response = $postController->show_action($request->query->get('id'));
} elseif ($uri == '/showuser' && $request->query->has('id')) {
    $userController = new UserController();
    $response = $userController->show_action($request->query->get('id'));
} elseif ($uri == '/admin') {
    $postController = new PostController();
    $response = $postController->admin_action();
} elseif ($uri == '/adminuser') {
    $userController = new UserController();
    $response = $userController->admin_action();
} elseif ($uri == '/add') {
    $postController = new PostController();
    echo "hello";
    $response = $postController->add_action();