PHP code example of openclerk / routing

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

    

openclerk / routing example snippets


Openclerk\Config::merge(array(
  "absolute_url" => "http://localhost/path/",
));


// router.php

"path", "security/login/password");

try {
  \Openclerk\Router::process($path);
} catch (\Openclerk\RouterException $e) {
  header("HTTP/1.0 404 Not Found");
  echo htmlspecialchars($e->getMessage());
}

// set up routes
\Openclerk\Router::addRoutes(array(
  "security/login/password" => "security/login.php?type=password",
  "security/login/:key" => "security/login-:key.php?type=:key",
  // by default any unmatched routes will 

<a href=" echo htmlspecialchars(url_for('security/login/password')); 

class MyApi {
  function render($args) {
    // $args = array('code' => ...)
  }
}

\Openclerk\Router::addRoutes(array(
  "api/currency/:code" => new MyApi(),
));

composer update --dev
vendor/bin/phpunit