Download the PHP package imponeer/smarty-sunrise-http-router without Composer
On this page you can find all versions of the php package imponeer/smarty-sunrise-http-router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download imponeer/smarty-sunrise-http-router
More information about imponeer/smarty-sunrise-http-router
Files in imponeer/smarty-sunrise-http-router
Package smarty-sunrise-http-router
Short Description Smarty extensions to use with amazing router from sunrise-php
License MIT
Informations about the package smarty-sunrise-http-router
Smarty Sunrise HTTP Router
This library exposes Sunrise HTTP Router named routes to Smarty through a {url} template function, allowing templates to generate links without hardcoding paths.
It is designed for applications that keep routing logic in Sunrise HTTP Router and want those routes available directly inside Smarty views.
Installation
To install and use this package, we recommend to use Composer:
Otherwise, you need to include manually files from src/ directory.
Setup
Modern Smarty Extension (Recommended)
Register the extension with your Smarty instance and provide a configured router:
Using with Dependency Injection Containers
Symfony Container
PHP-DI Container
League Container
Usage
The {url} function renders a URL for a named route defined in Sunrise HTTP Router.
Generate a route URL
Passing route attributes
Handling missing attributes
If required route attributes are not provided or the route name does not exist, the router will throw an exception so you can catch and handle the error in your application.
Development
Code Quality Tools
-
PHPUnit - For unit testing
-
PHP CodeSniffer - For coding standards (PSR-12)
- PHPStan - For static analysis
Documentation
Routes are defined and built using Sunrise HTTP Router, and Smarty extension details are available in the Smarty documentation. Review those resources for deeper customization tips.
Contributing
Contributions are welcome! Here's how you can contribute:
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature-name - Submit a pull request
Please make sure your code follows the PSR-12 coding standard and include tests for any new features or bug fixes.
If you find a bug or have a feature request, please create an issue in the issue tracker.
All versions of smarty-sunrise-http-router with dependencies
php Version ^8.1
sunrise/http-router Version ^3