Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/imponeer/smarty-sunrise-http-router

Smarty extensions to use with amazing router from @sunrise-php
https://github.com/imponeer/smarty-sunrise-http-router

hacktoberfest smarty smarty-plugins

Last synced: about 2 months ago
JSON representation

Smarty extensions to use with amazing router from @sunrise-php

Awesome Lists containing this project

README

        

[![License](https://img.shields.io/github/license/imponeer/smarty-sunrise-http-router.svg)](LICENSE)
[![GitHub release](https://img.shields.io/github/release/imponeer/smarty-sunrise-http-router.svg)](https://github.com/imponeer/smarty-sunrise-http-router/releases) [![PHP](https://img.shields.io/packagist/php-v/imponeer/smarty-sunrise-http-router.svg)](http://php.net)
[![Packagist](https://img.shields.io/packagist/dm/imponeer/smarty-sunrise-http-router.svg)](https://packagist.org/packages/imponeer/smarty-sunrise-http-router)

# Smarty Sunrise HTTP Router Extensions

This library adds some `url` function that generates named route for [Sunrise HTTP Router](https://github.com/sunrise-php/http-router).

## Installation

To install and use this package, we recommend to use [Composer](https://getcomposer.org):

```bash
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](https://www.smarty.net/docs/en/api.register.plugin.tpl) from [Smarty](https://www.smarty.net). For example:
```php
$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:
```smarty
go there
```

`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](https://skills.github.com).

If you found any bug or have some questions, use [issues tab](https://github.com/imponeer/smarty-sunrise-http-router/issues) and write there your questions.