Example #1
0
<?php

require_once 'Autoloader.php';
\SoftUni\Autoloader::register();
\SoftUni\Helpers\Session::start();
$phpSelf = $_SERVER['PHP_SELF'];
$index = basename($phpSelf);
\SoftUni\Helpers\RouteService::init(str_replace($index, '', $phpSelf));
$requestParams = [];
$controller = "users";
$action = "login";
if (isset($_GET['uri'])) {
    $requestParams = explode('/', $_GET['uri']);
    $controller = ucfirst(array_shift($requestParams));
    $action = ucfirst(array_shift($requestParams));
}
\SoftUni\Core\Database::setInstance(\SoftUni\Config\DatabaseConfig::DB_INSTANCE, \SoftUni\Config\DatabaseConfig::DB_DRIVER, \SoftUni\Config\DatabaseConfig::DB_USER, \SoftUni\Config\DatabaseConfig::DB_PASSWORD, \SoftUni\Config\DatabaseConfig::DB_NAME, \SoftUni\Config\DatabaseConfig::DB_HOST);
$app = new \SoftUni\Application($controller, $action, $requestParams);
$app->start();
<?php

use Softuni\Core\Database;
use Softuni\Config\DatabaseConfig;
use Softuni\App;
use Softuni\Autoloader;
session_start();
require_once 'Autoloader.php';
Autoloader::init();
if (isset($_GET['uri'])) {
    $uri = explode('/', rtrim($_GET['uri'], '/'));
    if (count($uri)) {
        $controllerName = array_shift($uri);
    }
    if (count($uri)) {
        $actionName = array_shift($uri);
    }
    $params = $uri;
}
Database::setInstance(DatabaseConfig::DB_INSTANCE_NAME, DatabaseConfig::DB_DRIVER, DatabaseConfig::DB_USERNAME, DatabaseConfig::DB_PASSWORD, DatabaseConfig::DB_NAME, DatabaseConfig::DB_HOST);
$app = new App($controllerName, $actionName, $params);
$app->start();