diff --git a/src/Illuminate/Cache/CacheServiceProvider.php b/src/Illuminate/Cache/CacheServiceProvider.php index e0616768e373..46fa0ae2615c 100755 --- a/src/Illuminate/Cache/CacheServiceProvider.php +++ b/src/Illuminate/Cache/CacheServiceProvider.php @@ -30,8 +30,6 @@ public function register() $this->app->singleton('memcached.connector', function () { return new MemcachedConnector; }); - - $this->app->singleton(RateLimiter::class); } /** @@ -42,7 +40,7 @@ public function register() public function provides() { return [ - 'cache', 'cache.store', 'cache.psr6', 'memcached.connector', RateLimiter::class, + 'cache', 'cache.store', 'cache.psr6', 'memcached.connector', ]; } } diff --git a/src/Illuminate/Cache/RateLimitingServiceProvider.php b/src/Illuminate/Cache/RateLimitingServiceProvider.php new file mode 100755 index 000000000000..ebc77600aef3 --- /dev/null +++ b/src/Illuminate/Cache/RateLimitingServiceProvider.php @@ -0,0 +1,31 @@ +app->singleton(RateLimiter::class); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return [ + RateLimiter::class, + ]; + } +} diff --git a/tests/Integration/Http/ThrottleRequestsTest.php b/tests/Integration/Http/ThrottleRequestsTest.php index c836f916ffa5..57d03b397e51 100644 --- a/tests/Integration/Http/ThrottleRequestsTest.php +++ b/tests/Integration/Http/ThrottleRequestsTest.php @@ -4,6 +4,7 @@ use Illuminate\Cache\RateLimiter; use Illuminate\Cache\RateLimiting\GlobalLimit; +use Illuminate\Cache\RateLimitingServiceProvider; use Illuminate\Container\Container; use Illuminate\Http\Exceptions\ThrottleRequestsException; use Illuminate\Routing\Middleware\ThrottleRequests; @@ -98,4 +99,9 @@ public function testLimitingUsingNamedLimiter() $this->assertEquals(Carbon::now()->addSeconds(2)->getTimestamp(), $e->getHeaders()['X-RateLimit-Reset']); } } + + protected function getPackageProviders($app) + { + return [RateLimitingServiceProvider::class]; + } } diff --git a/tests/Integration/Http/ThrottleRequestsWithRedisTest.php b/tests/Integration/Http/ThrottleRequestsWithRedisTest.php index 34b34d4f65ae..8f27c88b7ea7 100644 --- a/tests/Integration/Http/ThrottleRequestsWithRedisTest.php +++ b/tests/Integration/Http/ThrottleRequestsWithRedisTest.php @@ -2,6 +2,7 @@ namespace Illuminate\Tests\Integration\Http; +use Illuminate\Cache\RateLimitingServiceProvider; use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis; use Illuminate\Routing\Middleware\ThrottleRequestsWithRedis; use Illuminate\Support\Carbon; @@ -61,4 +62,9 @@ public function testLockOpensImmediatelyAfterDecay() } }); } + + protected function getPackageProviders($app) + { + return [RateLimitingServiceProvider::class]; + } }