PHP code example of jinexus-framework / jinexus-route
1. Go to this page and download the library: Download jinexus-framework/jinexus-route library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jinexus-framework / jinexus-route example snippets
use JiNexus\Route\Route\Route;
use JiNexus\Route\Route\Factory\RouteFactory;
use JiNexus\Route\Redirect\Redirect;
// Via the factory (builds and wires a Redirect for you)...
$route = RouteFactory::build();
// ...or explicitly.
$route = new Route(new Redirect());
$route->setRoutes([
'home' => ['route' => '/', 'controller' => HomeController::class],
'about' => ['route' => '/about-us', 'controller' => AboutController::class],
'user' => ['route' => '/user', 'controller' => UserController::class],
]);
$route->getRoutes(); // the full table
$route->setRoutes(); // called with no argument, resets to []
// Match an explicit URI.
$route->getMatchRoute([], '/about-us');
// ['about' => ['route' => '/about-us', 'controller' => AboutController::class]]
// Omit the URI to match against the current request.
$route->getMatchRoute();
// No match returns an empty array.
$route->getMatchRoute([], '/nope'); // []
use JiNexus\Route\Redirect\Redirect;
use JiNexus\Route\Redirect\Factory\RedirectFactory;
$redirect = RedirectFactory::build(); // or: new Redirect()
$redirect->setRoutes([
'home' => ['route' => '/'],
'about' => ['route' => '/about-us'],
]);
$redirect->toRoute('about'); // 302 Location: /about-us, then exits
$redirect->toRoute('about', true); // 301 Location: /about-us, then exits
$route->redirect; // the RedirectInterface
$route->getRedirect(); // same, through AbstractBase::__call()
$route->getRedirect(); // reads the public $redirect
$route->setRedirect($otherOne); // returns $route, so it chains
$redirect->getRoutes(); // throws: $routes is protected
// RouteException: Not implemented: JiNexus\Route\Redirect\Redirect::routes
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.