PHP code example of router / slim

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

    

router / slim example snippets


-
  url: /test[/{return}] (optional)
  method: get|post|put|head|delete
  routeBeforeInvoke:
    - [class]->[function]
    ...
  invoke: [class]->[function]
  return: json|raw|download (*optional)


EqnComparer\Util\Container;
use \Cs\Router\Util\App as Router;
$yaml = __DIR__ . '/app/Tnq/EqnComparer/Config/Routes.yaml';
$appYaml = __DIR__ . '/app/Tnq/EqnComparer/Config/Config.yaml';
$context = Container::getContext(
    ['routesConfig' => $yaml, 'appConfig' => $appYaml]
);
$routes = $context['routesConfig'];
$cors = $context['appConfig']['cors'];
try {
    $app = new Router([], $context, $routes, $cors);
    $app->run();
}
catch(Exception $e) {
    echo $e->getMessage();
}