imponeer / smarty-sunrise-http-router
Smarty extensions to use with amazing router from sunrise-php
Installs: 15 993
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- imponeer/smarty-extensions-contracts: ^3.0
- sunrise/http-router: ^3
Requires (Dev)
- phpunit/phpunit: ^8 || ^9
README
Smarty Sunrise HTTP Router Extensions
This library adds some url
function that generates named route for Sunrise HTTP Router.
Installation
To install and use this package, we recommend to use Composer:
composer require imponeer/smarty-sunrise-http-router
Otherwise, you need to include manually files from src/
directory.
Registering in Smarty
If you want to use these extensions from this package in your project you need register them with registerPlugin
function from Smarty. For example:
$smarty = new \Smarty(); $urlPlugin = new \Imponeer\Smarty\Extensions\SunriseHTTPRouter\UrlFunction($router); $smarty->registerPlugin('function', $urlPlugin->getName(), [$urlPlugin, 'execute']);
Using from templates
To generate url for named route:
<a href="{url name='ROUTE_NAME' attributes=['p1'=>'v1']}">go there</a>
attributes
can be used also as shortcut attr
or not used at all. This param maybe needed depending on a route.
How to contribute?
If you want to add some functionality or fix bugs, you can fork, change and create pull request. If you not sure how this works, try interactive GitHub tutorial.
If you found any bug or have some questions, use issues tab and write there your questions.