'nobody knows it (but you got a secret smile;)']); }); /** Examples of real-world route formats * * URL-format Proposals and common Route regex solutions * ----------------------------------------------------------------------------- * * Page (almost-static content): * /about/{url} # Route::add('/about/([0-9a-zA-Z-_\/]*)', function($url) { Page::fromUrl($url); }); * * Product: * /{level-1}/{level-2}/{level-3}/{friendly-url}-{id} # Route::add('/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)-([0-9]*)', # function($category, $subcategory, $group, $label, $id) { # Product::fromID([$$category, $subcategory, $group, $label], $id); # } # ); * * Category * /{category}/[ {subcategory}[ /{group}]] # Route::add('/([0-9a-zA-Z-_]*)', function($a) { Category::url([$a]); }; # Route::add('/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)', function($a, $b) { Category::url([$a, $b]); }); # Route::add('/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)', function($a, $b, $c) { Category::url([$a, $b, $c]); }); * * othet routes used in some user-cases * # Route::add('/lesson/([0-9a-f]*)/([0-9a-zA-Z-_]*)', # function($ticket, $lesson) { Lesson::show([$lesson, $ticket]); } # ); # # Route::add('/media/([0-9a-f]*)/([0-9a-zA-Z-_]*)/([0-9]*)/', # function($ticket, $type, $id) { Media::serve([$type, $id, $ticket]); } # ); * * 4-th level paths belong to products # Route::add('/about/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)/([0-9a-zA-Z-_]*)', # function($a, $b, $c) { Page::show([$a, $b, $c]); } # ); * * * OTHER EXAMPLES (use it for brainsrtorming) * ----------------------------------------------------------------------------- * * # // Typical Use # // --- # Route::add('/art', function() { Art::blah(); }); # Route::add('/art/db', function() { Art::fromDatabase(); }); # Route::add('/art/([0-9]*)', function($id) { Art::getInfo($id); }); * * Get-Post route example # Route::add('/contact-form', function() { # echo '
'; # }, 'get'); Route::add('/contact-form', function() { echo 'Hey! The form has been sent: