Ejemplo n.º 1
0
<?php

/**
 * @author  Rizart Dokollari <*****@*****.**>
 * @since   16/12/2015
 */
require __DIR__ . '/../vendor/autoload.php';
$dotenv = new Dotenv\Dotenv(__DIR__ . '/..');
$dotenv->load();
$dotenv->required(['BASE_URL'])->notEmpty();
$baseUrl = getenv('BASE_URL');
$mux = new \Pux\Mux();
$mux->get($baseUrl, ['App\\Controllers\\HomeController', 'home']);
$mux->get($baseUrl . "vessels(?pg=:id)", ['App\\Controllers\\VesselsController', 'index']);
$mux->get($baseUrl . "vessels/types", ['App\\Controllers\\VesselsController', 'types']);
$mux->get($baseUrl . "vessels/users/:id", ['App\\Controllers\\VesselsController', 'user']);
$mux->get($baseUrl . "companies(?pg=:id)", ['App\\Controllers\\CompaniesController', 'index']);
$mux->get($baseUrl . "users", ['App\\Controllers\\UsersController', 'index']);
$route = $mux->dispatch($_SERVER['REQUEST_URI']);
echo \Pux\Executor::execute($route);
Ejemplo n.º 2
0
$mux->get('', ['Module\\controllers\\WelcomeController', 'home']);
$mux->get('\\404', ['Module\\controllers\\WelcomeController', 'not_found']);
##################################Employee Section ##############################
#################################################################################
$mux->get('/employees', ['Module\\controllers\\EmployeesController', 'index']);
$mux->get('/employee/add', ['Module\\controllers\\EmployeesController', 'add']);
$mux->post('/employee/create', ['Module\\controllers\\EmployeesController', 'create']);
$mux->get('/employee/edit/:id', ['Module\\controllers\\EmployeesController', 'edit'], ['require' => ['id' => '\\d+']]);
$mux->post('/employee/update/:id', ['Module\\controllers\\EmployeesController', 'update'], ['require' => ['id' => '\\d+']]);
$mux->get('/employee/remove/:id', ['Module\\controllers\\EmployeesController', 'destroy'], ['require' => ['id' => '\\d+']]);
##################################End Employee Section ##############################
#####################################################################################
##################################SalaryController Section ##############################
#################################################################################
$mux->get('/salaries', ['Module\\controllers\\SalaryController', 'index']);
$mux->get('/salary/add/:id', ['Module\\controllers\\SalaryController', 'add'], ['require' => ['id' => '\\d+']]);
$mux->post('/salary/create/:id', ['Module\\controllers\\SalaryController', 'create']);
$mux->get('/salary/edit/:id', ['Module\\controllers\\SalaryController', 'edit'], ['require' => ['id' => '\\d+']]);
$mux->post('/salary/update/:id', ['Module\\controllers\\SalaryController', 'update'], ['require' => ['id' => '\\d+']]);
$mux->get('/salary/remove/:id', ['Module\\controllers\\SalaryController', 'destroy'], ['require' => ['id' => '\\d+']]);
##################################End salary Section ##############################
#####################################################################################
#dispatch result
$route = $mux->dispatch(rtrim($_SERVER["REQUEST_URI"], '/'));
//$strUri = strlen($_SERVER["REQUEST_URI"]) > 1 ?  rtrim($_SERVER["REQUEST_URI"], '/') : '/home';
//$route = $mux->dispatch($strUri);
if ($route) {
    echo RouteExecutor::execute($route);
} else {
    echo renderPage('errors/404');
}