PHP code example of lachie4145 / yaml-router

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

    

lachie4145 / yaml-router example snippets



ter = YamlRouter\Router::create();
$router->run();

$router = YamlRouter\Router::create(__DIR__ . '/config/routes.yaml');

class UserController
{
    public function show(array $params): string
    {
        return 'User: ' . $params['id'];
    }
}

$router = YamlRouter\Router::create();
echo $router->url('user.show', ['id' => '42']); // /users/42

$router = YamlRouter\Router::create(
    routeFile: __DIR__ . '/routes.yaml',
    cachePath: __DIR__ . '/storage/routes.cache.php'
);
$router->run();

$router  = YamlRouter\Router::create();
$adapter = new YamlRouter\PsrAdapter($router);

$psrResponse = $adapter->handle($psrRequest, $psrResponse);
yaml
waf:
  customRules:
    - file: app/Security/MyRules.php
      class: MyRules
      method: checkRequest