kayladnls / seesaw
Routing, forward and backward.
0.2.1
2015-08-03 22:02 UTC
Requires
- league/route: ~1.0
Requires (Dev)
- henrikbjorn/phpspec-code-coverage: ~1.0@dev
- phpspec/phpspec: ~2.2@dev
This package is not auto-updated.
Last update: 2024-10-26 17:53:43 UTC
README
Routing, backwards and forwards
Seesaw is a reverse routing ornamentation that sits on top of League/Route 1.*. 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;
Coming Soon:
This package will shortly be updated to work with the upcoming league/route 2.0