Giter VIP home page Giter VIP logo

php-route's Introduction

php-route - Standalone PHP Router

If you're looking for a standalone self-contained request routing component, this is your tool!

Example Usage (sorry, docs are sparse)

require_once('route.class.php');
// Define our routes
Route::$debug = false;
Route::init();

// Our login page
Route::add(APP_URL_LOGIN,  'login.php');
Route::add(APP_URL_LOGOUT, 'logout.php');

Route::add('/signup',      'signup.php');

//Route::add('/accounts/profile',   'accounts/profile.php');
//Route::add('/accounts/settings',  'accounts/settings.php');

Route::add( '/organization/new', 'organization/edit.php');
Route::add('^/organization/([0-9a-f]{8}-[^/]+)/edit$',    array('organization_guid'), 'organization/edit.php');
//Route::add('^/organization/([0-9a-f]{8}-[^/]+)/account$', array('organization_guid'), 'organization/account.php');
//Route::add('^/organization/([0-9a-f]{8}-[^/]+)/delete$',  array('organization_guid'), 'organization/delete.php');

Route::add('^/([^/]+)/_tag$',                               array('organization_slug'),                'tag/list.php');
Route::add('^/([^/]+)/_tag/new$',                           array('organization_slug'),                'tag/edit.php');
Route::add('^/([^/]+)/_tag/([0-9a-f]{8}-[^/]+)$',           array('organization_slug', 'tag_guid'),    'tag/detail.php');
Route::add('^/([^/]+)/_tag/([0-9a-f]{8}-[^/]+)/edit$',      array('organization_slug', 'tag_guid'),    'tag/edit.php');

Route::add('^/([^/]+)/_team$',                              array('organization_slug'),               'team/list.php');
Route::add('^/([^/]+)/_team/new$',                          array('organization_slug'),               'team/edit.php');
Route::add('^/([^/]+)/_team/([0-9a-f]{8}-[^/]+)$',          array('organization_slug', 'team_guid'),  'team/detail.php');
Route::add('^/([^/]+)/_team/([0-9a-f]{8}-[^/]+)/edit$',     array('organization_slug', 'team_guid'),  'team/edit.php');
  
Route::add('^/([^/]+)/_topic$',                             array('organization_slug'),               'topic/list.php');
Route::add('^/([^/]+)/_topic/new$',                         array('organization_slug'),               'topic/edit.php');
Route::add('^/([^/]+)/_topic/([0-9a-f]{8}-[^/]+)/edit$',    array('organization_slug', 'topic_guid'), 'topic/edit.php');
  
Route::add('^/([^/]+)/_settings$',                          array('organization_slug'),               'settings/home.php');
  
Route::add('^/([^/]+)/_action$',                            array('organization_slug'),                  'action/list.php');
Route::add('^/([^/]+)/_action/new$',                        array('organization_slug'),                  'action/edit.php');
Route::add('^/([^/]+)/_action/([0-9a-f]{8}-[^/]+)$',        array('organization_slug', 'action_guid'),   'action/detail.php');
Route::add('^/([^/]+)/_action/([0-9a-f]{8}-[^/]+)/edit$',   array('organization_slug', 'action_guid'),   'action/edit.php');

Route::add('^/([^/]+)/([^/]+)/_item/([0-9a-f]{8}-[^/]+)$', array('organization_slug', 'topic_key', 'item_guid'), 'item/detail.php');

Route::add('/privacy', 'page-privacy.php');
Route::add('/terms',   'page-terms.php');
Route::add('/contact', 'page-contact.php');
Route::add('/pricing', 'page-pricing.php');

// Default Route
if ( is_authenticated() ) {
	Route::add('/', 'welcome.php');
} else {
	Route::add('/', 'home.php');
}

// Check dynamic slug routes ( This is the most expensive route )
Route::add('^/([a-z0-9-]+)(?:/([^/]+)(?:/([^/]+))?)?', array('primary', 'secondary', 'tertiary'), array('dynamic' => 'check_org_slug'));

// Default 404 route
Route::add('^.*$', '404.php');

Route::run();

php-route's People

Contributors

jdsharp avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.