Skip to content

Commit

Permalink
Merge pull request bschmitt#3 from junaidnasir/master
Browse files Browse the repository at this point in the history
Service Provider for Laravel
  • Loading branch information
bschmitt committed Feb 1, 2016
2 parents 959589a + f12e6a2 commit 783a652
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ $app->register(Bschmitt\Amqp\LumenServiceProvider::class);
Open **config/app.php** and add the service provider and alias:

```php
'Bschmitt\Amqp\ServiceProvider',
'Bschmitt\Amqp\AmqpServiceProvider',
```

```php
Expand Down Expand Up @@ -166,4 +166,4 @@ Amqp::consume('queue-name', function ($message, $resolver) {

## License

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
53 changes: 53 additions & 0 deletions src/AmqpServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php namespace Bschmitt\Amqp;

use Bschmitt\Amqp\Consumer;
use Bschmitt\Amqp\Publisher;
use Illuminate\Support\ServiceProvider;

class AmqpServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;

/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->app->bind('Amqp', 'Bschmitt\Amqp\Amqp');
if (!class_exists('Amqp')) {
class_alias('Bschmitt\Amqp\Facades\Amqp', 'Amqp');
}
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('Bschmitt\Amqp\Publisher', function ($app) {
return new Publisher(config());
});
$this->app->singleton('Bschmitt\Amqp\Consumer', function ($app) {
return new Consumer(config());
});

}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return ['Amqp','Bschmitt\Amqp\Publisher' , 'Bschmitt\Amqp\Consumer'];
}
}

0 comments on commit 783a652

Please sign in to comment.