Skip to content

Commit e667eb3

Browse files
Merge pull request #6 from golonka/pull-request
Added built in support for Laravel 4
2 parents bbde930 + a5f8d97 commit e667eb3

4 files changed

Lines changed: 76 additions & 2 deletions

File tree

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,30 @@ You must instanciate a new instance of Tiny with a random alpha-numeric set. Do
4040

4141
## Using laravel?
4242

43-
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:
43+
If you're using laravel and want to use a more laravel-like and cleaner suntax syntax you only have to follow these steps.
44+
45+
First open your ``app/config/app.php`` file and scroll down to your providers and add
46+
```php
47+
'providers' => array(
48+
...
49+
'ZackKitzmiller\TinyServiceProvider',
50+
)
51+
```
52+
and then this to aliases
53+
```php
54+
'aliases' => array(
55+
...
56+
'Tiny' => 'ZackKitzmiller\Facades\Tiny',
57+
)
58+
```
59+
60+
Lastly you run ``php artisan config:publish zackkitzmiller/tiny`` and fill in your key.
61+
62+
### Usage in Laravel
4463
```php
4564
echo Tiny::to(5);
4665
// echos E
4766

4867
echo Tiny::from('E');
4968
// echos 5
50-
```
69+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php namespace ZackKitzmiller\Facades;
2+
3+
use Illuminate\Support\Facades\Facade;
4+
5+
class Tiny extends Facade {
6+
7+
protected static function getFacadeAccessor()
8+
{
9+
return 'tiny';
10+
}
11+
12+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php namespace ZackKitzmiller;
2+
3+
use Illuminate\Support\ServiceProvider;
4+
5+
class TinyServiceProvider extends ServiceProvider {
6+
7+
public function boot()
8+
{
9+
$this->package('zackkitzmiller/tiny', 'zackkitzmiller/tiny', __DIR__.'/../');
10+
}
11+
12+
public function register()
13+
{
14+
$this->app['tiny'] = $this->app->share(function($app)
15+
{
16+
$key = $app['config']['zackkitzmiller/tiny::key'];
17+
18+
return new Tiny($key);
19+
});
20+
}
21+
22+
public function provides()
23+
{
24+
return array('tiny');
25+
}
26+
27+
}

src/config/config.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
return array(
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| TinyPHP key
8+
|--------------------------------------------------------------------------
9+
|
10+
| Key that the Tiny class uses.
11+
|
12+
*/
13+
14+
'key' => '',
15+
16+
);

0 commit comments

Comments
 (0)