Example #1
0
 private function getRouter()
 {
     $routes = ['default' => ['route' => '/', 'module' => 'application', 'controller' => 'index', 'action' => 'index'], 'defaultAdmin' => ['route' => '/admin', 'module' => 'admin', 'controller' => 'index', 'action' => 'index'], 'user_edit' => ['route' => '/users/:id', 'module' => 'application', 'controller' => 'user', 'action' => 'edit', [':id' => '\\d+']], 'error_404' => ['route' => '/error', 'module' => 'application', 'controller' => 'error', 'action' => 'error'], 'redirect' => ['route' => '/redirect/contact', 'module' => 'application', 'controller' => 'index', 'action' => 'redirectTest']];
     $router = new Piano\Router();
     $router->setRoutes($routes);
     return $router;
 }
Example #2
0
<?php

session_start();
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../src/config/routes.php';
define(CAIXA_INI_FILE, __DIR__ . '/../src/config/config.ini');
$config = new Piano\Config\Ini(CAIXA_INI_FILE);
$configIni = $config->get();
if (getenv('APPLICATION_ENV') == 'development') {
    ini_set('display_errors', 1);
    error_reporting(-1);
}
$layoutPerModule = ['base' => ['application']];
$router = new Piano\Router();
$router->setRoutes($routes)->enableSearchEngineFriendly($configIni['enableFriendlyUrl']);
$app = new Piano\Application($config, $router);
$app->registerModulesLayout($layoutPerModule);
$app->run();