<?php /* |-------------------------------------------------------------------------- | Register The Auto Loader |-------------------------------------------------------------------------- | | Composer provides a convenient, automatically generated class loader for | our application. We just need to utilize it! We'll simply require it | into the script here so that we don't have to worry about manual | loading any of our classes later on. It feels nice to relax. | */ use Pux\Executor; require __DIR__ . '/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | | Once we have the application, we can handle the incoming request | and send the associated response back to | the client's browser allowing them to enjoy the creative | and wonderful application we have prepared for them. | */ $mux = new \Pux\Mux(); $mux->get('/', ['HubIT\\Controllers\\WelcomeController', 'index']); $route = $mux->dispatch($_SERVER['REQUEST_URI']); echo Executor::execute($route);
/** * Sets up Pux tests */ function setupPux(Benchmark $benchmark, $routes, $args) { $name = extension_loaded('pux') ? 'Pux ext' : 'Pux PHP'; $argString = implode('/', array_map(function ($i) { return ':arg' . $i; }, range(1, $args))); $str = $firstStr = $lastStr = ''; $router = new \Pux\Mux(); for ($i = 0; $i < $routes; $i++) { list($pre, $post) = getRandomParts(); $str = '/' . $pre . '/' . $argString . '/' . $post; if (0 === $i) { $firstStr = str_replace(':', '', $str); } $lastStr = str_replace(':', '', $str); $router->add($str, 'handler' . $i); } $benchmark->register(sprintf('%s - last route (%s routes)', $name, $routes), function () use($router, $lastStr) { $route = $router->match($lastStr); }); $benchmark->register(sprintf('%s - unknown route (%s routes)', $name, $routes), function () use($router) { $route = $router->match('/not-even-real'); }); }
<?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);
<?php return Pux\Mux::__set_state(array('id' => NULL, 'routes' => array(0 => array(0 => true, 1 => '#^ /hello /(?P<name>[^/]+?) $#xs', 2 => array(0 => 'HelloController', 1 => 'helloAction'), 3 => array('regex' => ' /hello /(?P<name>[^/]+?) ', 'compiled' => '#^ /hello /(?P<name>[^/]+?) $#xs', 'pattern' => '/hello/:name'))), 'routesById' => array(), 'staticRoutes' => array(), 'submux' => array(), 'expand' => true)); /* version */
<?php $mux = new \Pux\Mux(); $mux->any('/product', ['App\\Controller\\Product', 'listAction']); $mux->get('/product/:id', ['App\\Controller\\Product', 'itemAction'], ['require' => ['id' => '\\d+'], 'default' => ['id' => '1']]); $mux->post('/product/:id', ['App\\Controller\\Product', 'updateAction'], ['require' => ['id' => '\\d+'], 'default' => ['id' => '1']]); $mux->delete('/product/:id', ['App\\Controller\\Product', 'deleteAction'], ['require' => ['id' => '\\d+'], 'default' => ['id' => '1']]); return $mux;
<?php return Pux\Mux::__set_state(array('routes' => array(0 => array(0 => false, 1 => '/hello', 2 => array(0 => 'HelloController', 1 => 'helloAction'), 3 => array())), 'staticRoutes' => array(), 'routesById' => array(), 'submux' => array(), 'id' => NULL, 'expand' => true)); /* version */
<?php /** * Routing functionality * @author awlad <*****@*****.**> */ use Pux\RouteExecutor; $mux = new Pux\Mux(); $mux = new Pux\Mux(); ##################################Welcome Section ############################## ################################################################################# $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+']]);
<?php return Pux\Mux::__set_state(array('id' => NULL, 'routes' => array(0 => array(0 => false, 1 => '/', 2 => array(0 => '\\kingnetpay\\controllers\\HelloController', 1 => 'helloAction'), 3 => array('method' => 1))), 'routesById' => array(), 'staticRoutes' => array(), 'submux' => array(), 'expand' => true)); /* version */