Skip to content

Commit

Permalink
Added built in support for Laravel 4
Browse files Browse the repository at this point in the history
  • Loading branch information
juiceland committed Jan 20, 2014
1 parent 9795276 commit a5f8d97
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,30 @@ You must instanciate a new instance of Tiny with a random alpha-numeric set. Do

## Using laravel?

If you're using laravel and want to use a more laravel-like syntax you could use [this fork](https://github.com/golonka/tiny) which will allow you to use a syntax like this:
If you're using laravel and want to use a more laravel-like and cleaner suntax syntax you only have to follow these steps.

First open your ``app/config/app.php`` file and scroll down to your providers and add
```php
'providers' => array(
...
'ZackKitzmiller\TinyServiceProvider',
)
```
and then this to aliases
```php
'aliases' => array(
...
'Tiny' => 'ZackKitzmiller\Facades\Tiny',
)
```

Lastly you run ``php artisan config:publish zackkitzmiller/tiny`` and fill in your key.

### Usage in Laravel
```php
echo Tiny::to(5);
// echos E

echo Tiny::from('E');
// echos 5
```
```
12 changes: 12 additions & 0 deletions src/ZackKitzmiller/Facades/Tiny.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php namespace ZackKitzmiller\Facades;

use Illuminate\Support\Facades\Facade;

class Tiny extends Facade {

protected static function getFacadeAccessor()
{
return 'tiny';
}

}
27 changes: 27 additions & 0 deletions src/ZackKitzmiller/TinyServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php namespace ZackKitzmiller;

use Illuminate\Support\ServiceProvider;

class TinyServiceProvider extends ServiceProvider {

public function boot()
{
$this->package('zackkitzmiller/tiny', 'zackkitzmiller/tiny', __DIR__.'/../');
}

public function register()
{
$this->app['tiny'] = $this->app->share(function($app)
{
$key = $app['config']['zackkitzmiller/tiny::key'];

return new Tiny($key);
});
}

public function provides()
{
return array('tiny');
}

}
16 changes: 16 additions & 0 deletions src/config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

return array(

/*
|--------------------------------------------------------------------------
| TinyPHP key
|--------------------------------------------------------------------------
|
| Key that the Tiny class uses.
|
*/

'key' => '',

);

0 comments on commit a5f8d97

Please sign in to comment.