PHP code example of mrmadclown / ennodia

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

    

mrmadclown / ennodia example snippets


use MrMadClown\Ennodia\RouteCollection;
use MrMadClown\Ennodia\SingleRoute;
use MrMadClown\Ennodia\Router;
use MrMadClown\Ennodia\MiddlewareGroup;
use MrMadClown\Ennodia\RouteCollection;
use Symfony\Component\HttpFoundation\Request;

use App\Http\Controllers\IndexController;
use App\Container; // implements Psr\Container\ContainerInterface;

$routes = RouteCollection::collect([
    SingleRoute::get('#^index$#', IndexController::class),
]);
$request = Request::createFromGlobals();
$router = new Router(new Container(), $routes, new MiddlewareGroup([]));
$response = $router->handle($request);

 SingleRoute::get('#^user/(?P<userId>\d+)$#', UserController::class),
 SingleRoute::get('#^(?P<user>[a-z]+)/(?P<repository>[a-z]+)$#i', UserRepositoryController::class),

class UserController {
    public function get(int $userId): Response {
        //...
    }
}

class UserRepositoryController {
    public function __invoke(string $user, string $repository): Response {
        //...
    }
 }