Skip to content

Latest commit

 

History

History
36 lines (30 loc) · 1.19 KB

README.md

File metadata and controls

36 lines (30 loc) · 1.19 KB

Seesaw

Routing, backwards and forwards

Seesaw is a reverse routing ornamentation that sits on top of League/Route. All of the functionality of route is available, as well as the ability to reverse routes.

Usage:

Adding a named route.

  $seesaw = new Seesaw();
  $seesaw->addNamedRoute('JimBob', 'GET', 'url/jim/bob', function(){});
  echo $this->route('JimBob'); // will output: /url/jim/bob

Using a base url:

$seesaw->setBaseUrl('http://yolo.com');
$seesaw->addNamedRoute('JimBob', 'GET', 'url/jim/bob', function(){});
echo $this->route('JimBob'); // will output http://yolo.com/url/jim/bob

Relative and Secure URLs

$seesaw->setBaseUrl('http://yolo.com');
$seesaw->addNamedRoute('JimBob', 'GET', 'url/jim/bob', function(){});
echo $this->route('JimBob')->secure(); // will output https://yolo.com/url/jim/bob
echo $this->route('JimBob')->relative(); // will output /url/jim/bob

Using paramterized routes

$seesaw->addNamedRoute('JimBob', 'GET', 'url/jim/bob/{id}', function(){});
echo $seesaw->route('JimBob', [123]); // will output /url/jim/bob/123;

TODO

  • Add support for arrays as names with dot access