STB/blog/public/index.php

72 lines
1.9 KiB
PHP
Executable File

<?php
session_start();
require __DIR__ . "/../init.php";
$pathInfo = $_SERVER['PATH_INFO'];
//var_dump($pathInfo);die();
$routes = [
'/login' => [
'controller' => 'loginController',
'method' => 'login'
],
'/logout' => [
'controller' => 'loginController',
'method' => 'logout'
],
'/homepages' => [
'controller' => 'loginController',
'method' => 'homepages' // show Methode anwenden
],
'/index' => [
'controller' => 'postsController',
'method' => 'index'
],
'/index_c' => [
'controller' => 'postsController',
'method' => 'index_c'
],
'/dashboard' => [
'controller' => 'loginController',
'method' => 'dashboard'
],
'/post' => [
'controller' => 'postsController',
'method' => 'comment' //'show' //'comments'
],
'/post_c' => [
'controller' => 'postsController',
'method' => 'show' //'show' //'comments'
],
'/posts-admin' => [
'controller' => 'postsAdminController',
'method' => 'index'
],
'/posts-admin_c' => [
'controller' => 'postsAdminController',
'method' => 'post_c' //'method' => 'index_c'
],
'/posts-edit' => [
'controller' => 'postsAdminController',
'method' => 'edit'
],
'/posts-edit_c' => [
'controller' => 'postsAdminController',
'method' => 'edit_c'
],
'/impressum' => [
'controller' => 'loginController',
'method' => 'impressum' // index Methode anwenden
],
];
//var_dump($routes[$pathInfo]); die();
if (isset($routes[$pathInfo])) {
$route = $routes[$pathInfo];
$controller = $container->make($route['controller']);
$method = $route['method'];
//echo "method: ".$method." - ";
//var_dump($controller); die();
$controller->$method();
}
?>