From 86e1dabb511dd1e8e3675952466281866330e948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gamez?= Date: Sun, 23 Jun 2024 10:45:32 +0200 Subject: [PATCH] Defer Service Provider Registration --- CHANGELOG.md | 4 ++++ composer.json | 2 +- src/ServiceProvider.php | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35c7dda..4d518f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +* Service Provider Registration is now deferred. This should fix the credentials auto discovery in Laravel's + package discovery stage + ([#210](https://github.com/kreait/laravel-firebase/pull/210)) + ## 5.8.0 - 2024-03-13 * Added support for Laravel 11 diff --git a/composer.json b/composer.json index 4f99d7c..e6a0bdc 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ ], "require": { "php": "~8.1.0 || ~8.2.0 || ~8.3.0", - "kreait/firebase-php": "^7.0", + "kreait/firebase-php": "^7.13", "illuminate/contracts": "^9.0 || ^10.0 || ^11.0", "illuminate/support": "^9.0 || ^10.0 || ^11.0", "symfony/cache": "^6.1.2 || ^7.0.3" diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index c14930e..1e96902 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -5,9 +5,10 @@ namespace Kreait\Laravel\Firebase; use Illuminate\Contracts\Container\Container; +use Illuminate\Contracts\Support\DeferrableProvider; use Kreait\Firebase; -final class ServiceProvider extends \Illuminate\Support\ServiceProvider +final class ServiceProvider extends \Illuminate\Support\ServiceProvider implements DeferrableProvider { public function boot(): void { @@ -62,4 +63,19 @@ private function registerManager(): void $this->app->singleton(FirebaseProjectManager::class, static fn (Container $app) => new FirebaseProjectManager($app)); $this->app->alias(FirebaseProjectManager::class, 'firebase.manager'); } + + public function provides(): array + { + return [ + Firebase\Contract\AppCheck::class, + Firebase\Contract\Auth::class, + Firebase\Contract\Database::class, + Firebase\Contract\DynamicLinks::class, + Firebase\Contract\Firestore::class, + Firebase\Contract\Messaging::class, + Firebase\Contract\RemoteConfig::class, + Firebase\Contract\Storage::class, + FirebaseProjectManager::class, + ]; + } }