dev-master
9999999-dev https://github.com/jackjackdaw/silex-tinySilex service provider for Tiny library.
MIT
The Requires
- php >=5.3.0
- silex/silex ~2.0@dev
- zackkitzmiller/tiny 1.2.*
by Jack Jackdaw
silex tiny
Silex service provider for Tiny library.
A simple Silex Service Provider for Tiny by Zack Kitzmiller., (*1)
Install via composer, (*2)
$ composer require jackdaw/silex-tiny:dev-master
This will install the package and all the dependencies., (*3)
Before using Tiny, you need to create a random set. You can easily do this using the command line tools included in Tiny., (*4)
$ ./vendor/zackkitzmiller/tiny/bin/genset Generating TinyPHP Random Set... Set Generated Set: SJYaqGhd6mAe3NbWOB2KwfRtHslMFQkyXCu1gUI4cET97jZPp8nD5iVv0Loxzr
Now you have random set of characters for Tiny. Time to register the service provider for Silex., (*5)
<?php use Jackdaw\SilexTiny\TinyServiceProvider; // Create the Silex Application $app $app->register(new TinyServiceProvider(), array( 'tiny.options' => array('set' => 'SJYaqGhd6mAe3NbWOB2KwfRtHslMFQkyXCu1gUI4cET97jZPp8nD5iVv0Loxzr') ));
Passing the random set to the service provider is mandatory., (*6)
You can use the service like this, (*7)
echo $app['tiny']->to(5); // E echo $app['tiny']->from('E'); // 5 echo $app['tiny']->to(126); // XX echo $app['tiny']->from('XX'); // 126 echo $app['tiny']->to(999); // vk echo $app['tiny']->from('vk'); // 999
This package comes with an optional trait for using Tiny., (*8)
// In Application use \Jackdaw\SilexTiny\TinyTrait;
Now you can simply use Tiny like this, (*9)
echo $app->to(5); // E echo $app->from('E'); // 5
A custom Twig filter is also included in the package. It's just a one way transformation, at least at the moment. This is useful for transforming ids in the view layer of your application., (*10)
// In twig template {{ 5 | tiny }} // E
Silex service provider for Tiny library.
MIT
silex tiny