PHP code example of gephart / routing

1. Go to this page and download the library: Download gephart/routing 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/ */

    

gephart / routing example snippets




// $_GET["_route"] = "/admin/article/edit";

$container = new \Gephart\DependencyInjection\Container();

$configuration = $container->get(\Gephart\Configuration\Configuration::class);
$configuration->setDirectory(__DIR__ . "/config");

$router = $container->get(\Gephart\Routing\Router::class);

$route = new \Gephart\Routing\Route();
$route->setName("testing_route");
$route->setController("Test");
$route->setAction("index");
$route->setRule("/admin/{entity}/{action}");

$router->addRoute($route);

$router->run(); // Run controller Test and action method index

// /admin/article/post?id=21
$url = $router->generateUrl("testing_route", [
    "action" => "post",
    "entity" => "article",
    "id" => 21
]);



/**
 * @RoutePrefix /admin
 */
class AdminController
{
    /**
     * @Route {
     *  "rule": "/page/{slug}/{limit}/{offset}",
     *  "name": "homepage",
     *  "