From a5f8d971e50e9fdde40d96a1a94b7cde57ea9c5f Mon Sep 17 00:00:00 2001 From: Joseph Landberg Date: Mon, 20 Jan 2014 19:19:40 +0100 Subject: [PATCH] Added built in support for Laravel 4 --- README.md | 23 ++++++++++++++++-- src/ZackKitzmiller/Facades/Tiny.php | 12 ++++++++++ src/ZackKitzmiller/TinyServiceProvider.php | 27 ++++++++++++++++++++++ src/config/config.php | 16 +++++++++++++ 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 src/ZackKitzmiller/Facades/Tiny.php create mode 100644 src/ZackKitzmiller/TinyServiceProvider.php create mode 100644 src/config/config.php diff --git a/README.md b/README.md index 3117663..5ea560e 100644 --- a/README.md +++ b/README.md @@ -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 -``` +``` \ No newline at end of file diff --git a/src/ZackKitzmiller/Facades/Tiny.php b/src/ZackKitzmiller/Facades/Tiny.php new file mode 100644 index 0000000..d1cd555 --- /dev/null +++ b/src/ZackKitzmiller/Facades/Tiny.php @@ -0,0 +1,12 @@ +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'); + } + +} \ No newline at end of file diff --git a/src/config/config.php b/src/config/config.php new file mode 100644 index 0000000..481756e --- /dev/null +++ b/src/config/config.php @@ -0,0 +1,16 @@ + '', + +); \ No newline at end of file