Core Boxx – Route Library Reference

NOTES

  • This library requires Apache mod_rewrite to work properly.
  • Although you can always “translate” the .htaccess file for IIS and NGINX.

 

PRETTY URL

function run()

Reads the current URL and determines if it is an API call or request for an HTML page. Loads the requested file.

  • Sets define("API_MODE", 1) if it is http://site.com/api/*. Calls api().
  • Otherwise sets define("WEB_MODE", 1) if it is http://site.com/*. Calls resolve().
function htaccess()

Regenerates the .htaccess… The URL rewrite is “borrowed” from WordPress. If you have to support IIS or NGINX, feel free to add your own “translated .htaccess“.

 

 

HTML PAGE RESOLVE

function resolve()

Resolve URL path to HTML page. Add your own manual route overrides in lib/CORE-Routes.php

  • $override Has the highest priority.
  • $routes Exact matches have the next highest priority.
  • $wild Followed by wildcards.
  • Lastly, fallback to map http://site.com/PATH to pages/PAGE-PATH.php.
function load($file, $http)

A “helper function” for resolve(). You can also use this in your pages to load the given HTML page.

  • $file – String, file to load.
  • $http – Integer, optional HTTP response code.
$_CORE->Route->load("NO-ACCESS.PHP", 403);

 

API RESOLVE

function api()

Reads the current URL path http://site.com/api/MODULE/REQUEST and maps it to lib/API-MODULE.php.

Leave a Comment

Your email address will not be published.