RedisServiceProvider.php 942B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Illuminate\Redis;
  3. use Illuminate\Support\Arr;
  4. use Illuminate\Support\ServiceProvider;
  5. class RedisServiceProvider extends ServiceProvider
  6. {
  7. /**
  8. * Indicates if loading of the provider is deferred.
  9. *
  10. * @var bool
  11. */
  12. protected $defer = true;
  13. /**
  14. * Register the service provider.
  15. *
  16. * @return void
  17. */
  18. public function register()
  19. {
  20. $this->app->singleton('redis', function ($app) {
  21. $config = $app->make('config')->get('database.redis');
  22. return new RedisManager(Arr::pull($config, 'client', 'predis'), $config);
  23. });
  24. $this->app->bind('redis.connection', function ($app) {
  25. return $app['redis']->connection();
  26. });
  27. }
  28. /**
  29. * Get the services provided by the provider.
  30. *
  31. * @return array
  32. */
  33. public function provides()
  34. {
  35. return ['redis', 'redis.connection'];
  36. }
  37. }