2017 © Pedro Peláez
 

library laravel

Bernard bindings for Laravel

image

bernard/laravel

Bernard bindings for Laravel

  • Monday, August 5, 2013
  • by henrikbjorn
  • Repository
  • 4 Watchers
  • 14 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Bernard for Laravel

Build Status, (*1)

Brings Bernard to Laravel. Laravel already has a great queue.. That's right, but it only works with Laravel. If your project/company utilizes multiple frameworks, Bernard provides leverage., (*2)

Getting started

Extend composer.json file:, (*3)

``` json { "require": { "bernard/laravel": "@dev" } }, (*4)


Register the service provider in `app/config/app.php`: ``` php <?php // ... 'providers' => array( // .. 'Bernard\Laravel\BernardServiceProvider' // .. )

Choose Driver

Now you need to choose the Driver you want to use. Initialize the default config file with artisan:, (*5)

``` bash $ php artisan config:publish bernard/laravel, (*6)


This creates the file `app/config/packages/bernard/laravel/config.php`. ### Redis Config in `app/config/packages/bernard/laravel/config.php` ``` php <?php return array( 'driver' => 'predis', );

Setup predis in IoC:, (*7)

``` php <?php, (*8)

App::singleton('predis', function () { return new \Predis\Client(null, array( 'prefix' => 'bernard:' )); });, (*9)


Requires the `predis/predis` composer package. ### SQS Config in `app/config/packages/bernard/laravel/config.php` ``` php <?php return array( 'driver' => 'sqs', // optional: use prefetching for efficiency //'prefetch' => 10, // optional: pre-set queue name -> url mappings //'queue_urls' => array('some-queue' => 'https://sqs.eu-west-1.amazonaws.com/123123/some-queue', ...) );

Setup sqs in IoC:, (*10)

``` php <?php, (*11)

use Aws\Sqs\SqsClient;, (*12)

// ..., (*13)

App::singleton('sqs', function () { return SqsClient::factory(array( 'key' => 'Your AWS Access Key', 'secret' => 'Your AWS Secret Key', 'region' => 'Your AWS Region' )); });, (*14)


Requires the `aws/aws-sdk-php` composer package. ### Iron MQ Config in `app/config/packages/bernard/laravel/config.php` ``` php <?php return array( 'driver' => 'iron_mq', // use prefetching for efficiency //'prefetch' => 10 );

Setup iron_mq in IoC:, (*15)

``` php <?php, (*16)

App::singleton('iron_mq', function () { return new \IronMq(array( 'token' => 'Your IronMQ Token', 'project_id' => 'Your IronMQ Project ID', )); });, (*17)


### Eloquent For small projects or testing. Config in `app/config/packages/bernard/laravel/config.php` ``` php <?php return array( 'driver' => 'eloquent', );

You also need to migrate the required tables (once):, (*18)

``` bash $ php artisan migrate --package=bernard/laravel, (*19)


Usage ----- ### In Laravel without Facades In your Laravel app, add a new message to the queue: ``` php <?php $this->app['bernard:producer']->produce(new \Bernard\Message\DefaultMessage('MyService', array( 'my' => 'args', )));

In Laravel with Facades

Add the two aliases in your app/config/app.php config file like so:, (*20)

``` php <?php, (*21)

return array( // .. 'aliases' => array( // .. 'Producer' => 'Bernard\Laravel\Facades\Producer', 'Consumer' => 'Bernard\Laravel\Facades\Consumer', ), );, (*22)


And now you can use them as any other Facade in Laravel: ``` php <?php Producer::message('MyService', array('my' => 'args'));

From command line

``` bash, (*23)

create a new message

$ php artisan bernard:produce MyService '{"json":"data"}', (*24)

consume messages

$ php artisan bernard:consume my-service ```, (*25)

The Versions

05/08 2013

dev-master

9999999-dev

Bernard bindings for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel queue worker serviceprovider bernard service-provider