├── LICENSE ├── src ├── Facades │ └── Firebase.php ├── FirebaseProject.php ├── ServiceProvider.php └── FirebaseProjectManager.php ├── composer.json ├── .php_cs.dist ├── README.md ├── CHANGELOG.md └── config └── firebase.php /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Jérôme Gamez, https://github.com/jeromegamez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Facades/Firebase.php: -------------------------------------------------------------------------------- 1 | in(['config', 'src', 'tests']); 7 | 8 | return (new PhpCsFixer\Config()) 9 | ->setUsingCache(true) 10 | ->setRiskyAllowed(true) 11 | ->setRules([ 12 | '@Symfony' => true, 13 | 'align_multiline_comment' => true, 14 | 'array_indentation' => true, 15 | 'array_syntax' => ['syntax' => 'short'], 16 | 'combine_consecutive_issets' => true, 17 | 'date_time_immutable' => true, 18 | 'declare_strict_types' => true, 19 | 'function_to_constant' => true, 20 | 'header_comment' => ['header' => ''], 21 | // 'mb_str_functions' => true, 22 | 'method_chaining_indentation' => true, 23 | 'multiline_whitespace_before_semicolons' => true, 24 | 'native_constant_invocation' => true, 25 | 'native_function_invocation' => true, 26 | 'no_alternative_syntax' => true, 27 | 'no_homoglyph_names' => true, 28 | 'no_null_property_initialization' => true, 29 | 'no_superfluous_elseif' => true, 30 | 'no_superfluous_phpdoc_tags' => [ 31 | 'allow_mixed' => true, 32 | ], 33 | 'no_useless_else' => true, 34 | 'nullable_type_declaration_for_default_null_value' => [ 35 | 'use_nullable_type_declaration' => true, 36 | ], 37 | 'ordered_imports' => true, 38 | 'ordered_interfaces' => true, 39 | 'phpdoc_line_span' => [ 40 | 'const' => 'single', 41 | 'property' => 'single', 42 | ], 43 | 'phpdoc_no_empty_return' => true, 44 | 'php_unit_expectation' => true, 45 | 'php_unit_internal_class' => true, 46 | 'php_unit_method_casing' => null, 47 | 'php_unit_mock' => true, 48 | 'php_unit_mock_short_will_return' => true, 49 | 'php_unit_namespaced' => true, 50 | 'php_unit_no_expectation_annotation' => true, 51 | 'php_unit_set_up_tear_down_visibility' => true, 52 | 'php_unit_test_case_static_method_calls' => [ 53 | 'call_type' => 'this', 54 | ], 55 | 'phpdoc_align' => false, 56 | 'phpdoc_order' => true, 57 | 'phpdoc_trim_consecutive_blank_line_separation' => true, 58 | 'simple_to_complex_string_variable' => true, 59 | 'single_line_throw' => false, 60 | 'static_lambda' => true, 61 | // 'void_return' => true, 62 | 'yoda_style' => false, 63 | ]) 64 | ->setFinder($finder); 65 | -------------------------------------------------------------------------------- /src/FirebaseProject.php: -------------------------------------------------------------------------------- 1 | factory = $factory; 42 | $this->config = $config; 43 | } 44 | 45 | public function appCheck(): AppCheck 46 | { 47 | if (! $this->appCheck) { 48 | $this->appCheck = $this->factory->createAppCheck(); 49 | } 50 | 51 | return $this->appCheck; 52 | } 53 | 54 | public function auth(): Auth 55 | { 56 | if (! $this->auth) { 57 | $this->auth = $this->factory->createAuth(); 58 | } 59 | 60 | return $this->auth; 61 | } 62 | 63 | public function database(): Database 64 | { 65 | if (! $this->database) { 66 | $this->database = $this->factory->createDatabase(); 67 | } 68 | 69 | return $this->database; 70 | } 71 | 72 | public function dynamicLinks(): DynamicLinks 73 | { 74 | if (! $this->dynamicLinks) { 75 | $this->dynamicLinks = $this->factory->createDynamicLinksService($this->config['dynamic_links']['default_domain'] ?? null); 76 | } 77 | 78 | return $this->dynamicLinks; 79 | } 80 | 81 | public function firestore(): Firestore 82 | { 83 | if (! $this->firestore) { 84 | $this->firestore = $this->factory->createFirestore(); 85 | } 86 | 87 | return $this->firestore; // @codeCoverageIgnore 88 | } 89 | 90 | public function messaging(): Messaging 91 | { 92 | if (! $this->messaging) { 93 | $this->messaging = $this->factory->createMessaging(); 94 | } 95 | 96 | return $this->messaging; 97 | } 98 | 99 | public function remoteConfig(): RemoteConfig 100 | { 101 | if (! $this->remoteConfig) { 102 | $this->remoteConfig = $this->factory->createRemoteConfig(); 103 | } 104 | 105 | return $this->remoteConfig; 106 | } 107 | 108 | public function storage(): Storage 109 | { 110 | if (! $this->storage) { 111 | $this->storage = $this->factory->createStorage(); 112 | } 113 | 114 | return $this->storage; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/ServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->runningInConsole()) { 16 | return; 17 | } 18 | // @codeCoverageIgnoreEnd 19 | 20 | $this->publishes([ 21 | __DIR__.'/../config/firebase.php' => $this->app->configPath('firebase.php'), 22 | ], 'config'); 23 | } 24 | 25 | public function register(): void 26 | { 27 | $this->mergeConfigFrom(__DIR__.'/../config/firebase.php', 'firebase'); 28 | 29 | $this->registerManager(); 30 | $this->registerComponents(); 31 | } 32 | 33 | private function registerComponents(): void 34 | { 35 | $this->app->singleton(Firebase\Contract\AppCheck::class, static fn (Container $app) => $app->make(FirebaseProjectManager::class)->project()->appCheck()); 36 | $this->app->alias(Firebase\Contract\AppCheck::class, 'firebase.app_check'); 37 | 38 | $this->app->singleton(Firebase\Contract\Auth::class, static fn (Container $app) => $app->make(FirebaseProjectManager::class)->project()->auth()); 39 | $this->app->alias(Firebase\Contract\Auth::class, 'firebase.auth'); 40 | 41 | $this->app->singleton(Firebase\Contract\Database::class, static fn (Container $app) => $app->make(FirebaseProjectManager::class)->project()->database()); 42 | $this->app->alias(Firebase\Contract\Database::class, 'firebase.database'); 43 | 44 | $this->app->singleton(Firebase\Contract\DynamicLinks::class, static fn (Container $app) => $app->make(FirebaseProjectManager::class)->project()->dynamicLinks()); 45 | $this->app->alias(Firebase\Contract\DynamicLinks::class, 'firebase.dynamic_links'); 46 | 47 | $this->app->singleton(Firebase\Contract\Firestore::class, static fn (Container $app) => $app->make(FirebaseProjectManager::class)->project()->firestore()); 48 | $this->app->alias(Firebase\Contract\Firestore::class, 'firebase.firestore'); 49 | 50 | $this->app->singleton(Firebase\Contract\Messaging::class, static fn (Container $app) => $app->make(FirebaseProjectManager::class)->project()->messaging()); 51 | $this->app->alias(Firebase\Contract\Messaging::class, 'firebase.messaging'); 52 | 53 | $this->app->singleton(Firebase\Contract\RemoteConfig::class, static fn (Container $app) => $app->make(FirebaseProjectManager::class)->project()->remoteConfig()); 54 | $this->app->alias(Firebase\Contract\RemoteConfig::class, 'firebase.remote_config'); 55 | 56 | $this->app->singleton(Firebase\Contract\Storage::class, static fn (Container $app) => $app->make(FirebaseProjectManager::class)->project()->storage()); 57 | $this->app->alias(Firebase\Contract\Storage::class, 'firebase.storage'); 58 | } 59 | 60 | private function registerManager(): void 61 | { 62 | $this->app->singleton(FirebaseProjectManager::class, static fn (Container $app) => new FirebaseProjectManager($app)); 63 | $this->app->alias(FirebaseProjectManager::class, 'firebase.manager'); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/FirebaseProjectManager.php: -------------------------------------------------------------------------------- 1 | app = $app; 26 | } 27 | 28 | public function project(?string $name = null): FirebaseProject 29 | { 30 | $name = $name ?? $this->getDefaultProject(); 31 | 32 | if (! isset($this->projects[$name])) { 33 | $this->projects[$name] = $this->configure($name); 34 | } 35 | 36 | return $this->projects[$name]; 37 | } 38 | 39 | protected function configuration(string $name): array 40 | { 41 | $config = $this->app->config->get('firebase.projects.'.$name); 42 | 43 | if (! $config) { 44 | throw new InvalidArgumentException("Firebase project [{$name}] not configured."); 45 | } 46 | 47 | return $config; 48 | } 49 | 50 | protected function resolveJsonCredentials(string $credentials): string 51 | { 52 | $isJsonString = \str_starts_with($credentials, '{'); 53 | $isAbsoluteLinuxPath = \str_starts_with($credentials, '/'); 54 | $isAbsoluteWindowsPath = \str_contains($credentials, ':\\'); 55 | 56 | $isRelativePath = ! $isJsonString && ! $isAbsoluteLinuxPath && ! $isAbsoluteWindowsPath; 57 | 58 | return $isRelativePath ? $this->app->basePath($credentials) : $credentials; 59 | } 60 | 61 | protected function configure(string $name): FirebaseProject 62 | { 63 | $factory = new Factory(); 64 | 65 | $config = $this->configuration($name); 66 | 67 | if ($tenantId = $config['auth']['tenant_id'] ?? null) { 68 | $factory = $factory->withTenantId($tenantId); 69 | } 70 | 71 | if ($credentials = $config['credentials']['file'] ?? ($config['credentials'] ?? null)) { 72 | if (is_string($credentials)) { 73 | $credentials = $this->resolveJsonCredentials($credentials); 74 | } 75 | 76 | $factory = $factory->withServiceAccount($credentials); 77 | } 78 | 79 | if ($databaseUrl = $config['database']['url'] ?? null) { 80 | $factory = $factory->withDatabaseUri($databaseUrl); 81 | } 82 | 83 | if ($authVariableOverride = $config['database']['auth_variable_override'] ?? null) { 84 | $factory = $factory->withDatabaseAuthVariableOverride($authVariableOverride); 85 | } 86 | 87 | if ($firestoreDatabase = $config['firestore']['database'] ?? null) { 88 | $factory = $factory->withFirestoreDatabase($firestoreDatabase); 89 | } 90 | 91 | if ($defaultStorageBucket = $config['storage']['default_bucket'] ?? null) { 92 | $factory = $factory->withDefaultStorageBucket($defaultStorageBucket); 93 | } 94 | 95 | if ($cacheStore = $config['cache_store'] ?? null) { 96 | $cache = $this->app->make('cache')->store($cacheStore); 97 | 98 | if ($cache instanceof CacheInterface) { 99 | $cache = new Psr16Adapter($cache); 100 | } else { 101 | throw new InvalidArgumentException('The cache store must be an instance of a PSR-6 or PSR-16 cache'); 102 | } 103 | 104 | $factory = $factory 105 | ->withVerifierCache($cache) 106 | ->withAuthTokenCache($cache); 107 | } 108 | 109 | if ($logChannel = $config['logging']['http_log_channel'] ?? null) { 110 | $factory = $factory->withHttpLogger( 111 | $this->app->make('log')->channel($logChannel) 112 | ); 113 | } 114 | 115 | if ($logChannel = $config['logging']['http_debug_log_channel'] ?? null) { 116 | $factory = $factory->withHttpDebugLogger( 117 | $this->app->make('log')->channel($logChannel) 118 | ); 119 | } 120 | 121 | $options = HttpClientOptions::default(); 122 | 123 | if ($proxy = $config['http_client_options']['proxy'] ?? null) { 124 | $options = $options->withProxy($proxy); 125 | } 126 | 127 | if ($timeout = $config['http_client_options']['timeout'] ?? null) { 128 | $options = $options->withTimeOut((float) $timeout); 129 | } 130 | 131 | if ($middlewares = $config['http_client_options']['guzzle_middlewares'] ?? null) { 132 | $options = $options->withGuzzleMiddlewares($middlewares); 133 | } 134 | 135 | $factory = $factory->withHttpClientOptions($options); 136 | 137 | return new FirebaseProject($factory, $config); 138 | } 139 | 140 | public function getDefaultProject(): string 141 | { 142 | return $this->app->config->get('firebase.default'); 143 | } 144 | 145 | public function setDefaultProject(string $name): void 146 | { 147 | $this->app->config->set('firebase.default', $name); 148 | } 149 | 150 | public function __call($method, $parameters) 151 | { 152 | // Pass call to default project 153 | return $this->project()->{$method}(...$parameters); 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Firebase for Laravel 2 | 3 | A Laravel package for the [Firebase PHP Admin SDK](https://github.com/kreait/firebase-php). 4 | 5 | [![Current version](https://img.shields.io/packagist/v/kreait/laravel-firebase.svg?logo=composer)](https://packagist.org/packages/kreait/laravel-firebase) 6 | [![Monthly Downloads](https://img.shields.io/packagist/dm/kreait/laravel-firebase.svg)](https://packagist.org/packages/kreait/laravel-firebase/stats) 7 | [![Total Downloads](https://img.shields.io/packagist/dt/kreait/laravel-firebase.svg)](https://packagist.org/packages/kreait/laravel-firebase/stats) 8 | [![Tests](https://github.com/kreait/laravel-firebase/workflows/Tests/badge.svg?branch=main)](https://github.com/kreait/laravel-firebase/actions) 9 | [![codecov](https://codecov.io/gh/kreait/laravel-firebase/branch/main/graph/badge.svg)](https://codecov.io/gh/kreait/laravel-firebase) 10 | [![Sponsor](https://img.shields.io/static/v1?logo=GitHub&label=Sponsor&message=%E2%9D%A4&color=ff69b4)](https://github.com/sponsors/jeromegamez) 11 | 12 | --- 13 | 14 | ## The future of the Firebase Admin PHP SDK 15 | 16 | Please read about the future of the Firebase Admin PHP SDK on the 17 | [SDK's GitHub Repository](https://github.com/kreait/firebase-php). 18 | 19 | --- 20 | 21 | - [Installation](#installation) 22 | - [Laravel](#laravel) 23 | - [Configuration](#configuration) 24 | - [Credentials with JSON files](#credentials-with-json-files) 25 | - [Credentials with Arrays](#credentials-with-arrays) 26 | - [Usage](#usage) 27 | - [Multiple projects](#multiple-projects) 28 | - [Supported Versions](#supported-versions) 29 | - [License](#license) 30 | 31 | ## Installation 32 | 33 | ```bash 34 | composer require kreait/laravel-firebase 35 | ``` 36 | 37 | ## Configuration 38 | 39 | In order to access a Firebase project and its related services using a server SDK, requests must be authenticated. 40 | For server-to-server communication this is done with a Service Account. 41 | 42 | If you don't already have generated a Service Account, you can do so by following the instructions from the 43 | official documentation pages at https://firebase.google.com/docs/admin/setup#initialize_the_sdk. 44 | 45 | Once you have downloaded the Service Account JSON file, you can configure the package by specifying 46 | environment variables starting with `FIREBASE_` in your `.env` file. Usually, the following are 47 | required for the package to work: 48 | 49 | ``` 50 | # You can find the database URL for your project at 51 | # https://console.firebase.google.com/project/_/database 52 | FIREBASE_DATABASE_URL=https://.firebaseio.com 53 | ``` 54 | 55 | For further configuration, please see [config/firebase.php](config/firebase.php). You can modify the configuration 56 | by copying it to your local `config` directory or by defining the environment variables used in the config file: 57 | 58 | ```bash 59 | # Laravel 60 | php artisan vendor:publish --provider="Kreait\Laravel\Firebase\ServiceProvider" --tag=config 61 | ``` 62 | 63 | ### Credentials with JSON files 64 | 65 | The package uses auto discovery for the default project to find the credentials needed for authenticating requests to 66 | the Firebase APIs by inspecting certain environment variables and looking into Google's well known path(s). 67 | 68 | If you don't want a service account to be auto-discovered, provide it by setting the `FIREBASE_CREDENTIALS` or `GOOGLE_APPLICATION_CREDENTIALS` environment variable or by adapting the package configuration, like so for example: 69 | 70 | ```.env 71 | FIREBASE_CREDENTIALS=storage/app/firebase-auth.json 72 | ``` 73 | 74 | ### Credentials with Arrays 75 | 76 | If you prefer to have more control over the configuration items required to configure the credentials, you can also transpose the Service Account JSON file as an array within your `config/firebase.php` file. 77 | 78 | ```php 79 | 'credentials' => [ 80 | 'type' => 'service_account', 81 | 'project_id' => 'some-project-123', 82 | 'private_key_id' => '123456789', 83 | 'private_key' => '-----BEGIN PRIVATE KEY-----\nFOO_BAR_123456789\n-----END PRIVATE KEY-----\n', 84 | 'client_email' => 'firebase-adminsdk-cwiuo@some-project-123.iam.gserviceaccount.com', 85 | 'client_id' => '123456789', 86 | 'auth_uri' => 'https://accounts.google.com/o/oauth2/auth', 87 | 'token_uri' => 'https://oauth2.googleapis.com/token', 88 | 'auth_provider_x509_cert_url' => 'https://www.googleapis.com/oauth2/v1/certs', 89 | 'client_x509_cert_url' => 'https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-cwiuo%40some-project-123.iam.gserviceaccount.com', 90 | 'universe_domain' => 'googleapis.com', 91 | ], 92 | ``` 93 | 94 | ## Usage 95 | 96 | Once you have retrieved a component, please refer to the [documentation of the Firebase PHP Admin SDK](https://firebase-php.readthedocs.io) 97 | for further information on how to use it. 98 | 99 | **You don't need and should not use the `new Factory()` pattern described in the SDK documentation, this is already 100 | done for you with the Laravel Service Provider. Use Dependency Injection, the Facades or the `app()` helper instead** 101 | 102 | ### Multiple projects 103 | 104 | Multiple projects can be configured in [config/firebase.php](config/firebase.php) by adding another section to the projects array. 105 | 106 | When accessing components, the facade uses the default project. You can also explicitly use a project: 107 | 108 | ```php 109 | use Kreait\Laravel\Firebase\Facades\Firebase; 110 | 111 | // Return an instance of the Auth component for the default Firebase project 112 | $defaultAuth = Firebase::auth(); 113 | // Return an instance of the Auth component for a specific Firebase project 114 | $appAuth = Firebase::project('app')->auth(); 115 | $anotherAppAuth = Firebase::project('another-app')->auth(); 116 | ``` 117 | 118 | ## Supported Versions 119 | 120 | **Only the latest version is actively supported.** 121 | 122 | Earlier versions will receive security fixes as long as their **lowest** SDK requirement receives security fixes. You 123 | can find the currently supported versions and support options in the [SDK's README](https://github.com/kreait/firebase-php). 124 | 125 | | Version | Initial Release | Supported SDK Versions | Supported Laravel Versions | Status | 126 | |---------|-----------------|------------------------|----------------------------|-------------| 127 | | `5.x` | 13 Jan 2023 | `^7.0` | `^9.0`, `^10.0` | Active | 128 | | `4.x` | 09 Jan 2022 | `^6.0` | `^8.0` | End of life | 129 | | `3.x` | 01 Nov 2020 | `^5.24` | `^6.0, ^7.0, ^8.0` | End of life | 130 | | `2.x` | 01 Apr 2020 | `^5.0` | `^5.8, ^6.0, ^7.0, ^8.0` | End of life | 131 | | `1.x` | 17 Aug 2019 | `^4.40.1` | `^5.8, ^6.0, ^7.0` | End of life | 132 | 133 | ## License 134 | 135 | This project is licensed under the [MIT License](LICENSE). 136 | 137 | Your use of Firebase is governed by the [Terms of Service for Firebase Services](https://firebase.google.com/terms/). 138 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ## Unreleased 4 | 5 | ## 5.7.0 - 2024-02-19 6 | 7 | * Enabled using `symfony/cache:^7` 8 | 9 | ## 5.6.0 - 2024-01-13 10 | 11 | * Added support for overriding the name of the Firestore Default Database 12 | ([#209](https://github.com/kreait/laravel-firebase/pull/209)) 13 | 14 | ## 5.5.0 - 2023-11-30 15 | 16 | * Added support for PHP 8.3 17 | 18 | ## 5.4.0 - 2023-10-05 19 | 20 | * Added support for configuration of credentials with a config array 21 | ([#202](https://github.com/kreait/laravel-firebase/pull/202)) 22 | 23 | ## 5.3.0 - 2023-07-26 24 | 25 | * Enabled injecting middlewares into the Firebase API client 26 | ([#187](https://github.com/kreait/laravel-firebase/pull/187)) 27 | 28 | ## 5.2.0 - 2023-03-30 29 | 30 | * Added AppCheck support 31 | ([#174](https://github.com/kreait/laravel-firebase/pull/174)) 32 | 33 | ## 5.1.0 - 2023-02-15 34 | 35 | * Added support for Laravel 10 36 | 37 | ## 5.0.0 - 2023-01-13 38 | 39 | * Upgraded `kreait/firebase-php` from 6.x to 7.x 40 | * Dropped support for PHP <8.1, Laravel <9.0 41 | * Dropped support for Lumen ([it is not recommended anymore to use it](https://github.com/laravel/lumen/commit/69b26578d2f15595ea901278434b74df459c4329)) 42 | * The ability to disable credentials auto-discovery has been removed. If you don't want a service account to be 43 | auto-discovered, provide it by setting the `GOOGLE_APPLICATION_CREDENTIALS` environment variable or by modifying 44 | the package configuration. 45 | 46 | ## 4.2.0 - 2022-07-28 47 | 48 | * Bumped dependencies, the minimum version of the underlying SDK is now 6.7.0. 49 | * Updated comment in `config/firebase.php` to reference the default HTTP timeout 50 | * With `kreait/firebase` 6.7.0, the default was changed from ∞ to 30 seconds. 51 | 52 | ## 4.1.0 - 2022-02-08 53 | 54 | * Added support for Laravel 9 ([#118](https://github.com/kreait/laravel-firebase/pull/118)) 55 | 56 | ## 4.0.0 - 2022-01-09 57 | 58 | This is a release with breaking changes. Please review the following changes and adapt your application where needed. 59 | 60 | ### Changes 61 | 62 | * Added support for `kreait/firebase-php` ^6.0 63 | * Dropped support for `kreait/firebase-php` <6.0 64 | * Dropped support for Laravel/Lumen <8.0 65 | * Removed deprecated Facades - use the `Kreait\Laravel\Firebase\Facades\Firebase` facade instead 66 | * `Kreait\Laravel\Firebase\Facades\FirebaseAuth` 67 | * `Kreait\Laravel\Firebase\Facades\FirebaseDatabase` 68 | * `Kreait\Laravel\Firebase\Facades\FirebaseDynamicLinks` 69 | * `Kreait\Laravel\Firebase\Facades\FirebaseFirestore` 70 | * `Kreait\Laravel\Firebase\Facades\FirebaseMessaging` 71 | * `Kreait\Laravel\Firebase\Facades\FirebaseRemoteConfig` 72 | * `Kreait\Laravel\Firebase\Facades\FirebaseStorage` 73 | * Removed support deprecated config options and environment variables 74 | * `$config['debug']`/`FIREBASE_ENABLE_DEBUG`, use the `http_debug_log_channel` config option instead 75 | 76 | ## 3.4.0 - 2021-12-04 77 | ### Added 78 | * Added support for caching the authentication tokens used for connecting to the Firebase servers. 79 | 80 | ## 3.3.0 - 2021-11-29 81 | ### Added 82 | * Ensure support for all PHP 8.x versions 83 | ([#110](https://github.com/kreait/laravel-firebase/pull/110)) 84 | 85 | ## 3.2.0 - 2021-10-21 86 | ### Added 87 | * Support for Database Auth Variable Overrides 88 | ([#93](https://github.com/kreait/laravel-firebase/pull/93)) 89 | ### Changed 90 | * Type-hints have been updated to point to the interfaces that the underlying SDK provides 91 | since more recent versions. 92 | * Bumped `kreait/firebase-php` dependency to `^5.24` (Database Auth Variable Overrides are supported since `5.22`) 93 | 94 | ## 3.1.0 - 2021-02-03 95 | ### Added 96 | * Support for tenant awareness via `FIREBASE_AUTH_TENANT_ID` environment variable 97 | or `firebase.projects.*.auth.tenant_id` config variable. 98 | ([#79](https://github.com/kreait/laravel-firebase/pull/79)) 99 | (thanks to [@sl0wik](https://github.com/sl0wik)) 100 | 101 | ## 3.0.0 - 2020-11-01 102 | ### Added 103 | * Support for multiple firebase projects (thanks to [@dododedodonl](https://github.com/dododedodonl)). 104 | * `\Kreait\Laravel\Firebase\Facades\Firebase` facade 105 | * HTTP Client Options are now configurable (thanks to [@kakajansh](https://github.com/kakajansh)) 106 | 107 | ### Changed 108 | * [config/firebase.php](config/firebase.php) has a new format to support multiple projects 109 | 110 | ### Deprecated 111 | * Use of `FirebaseAuth`, `FirebaseDatabase`, `FirebaseDynamicLinks`, `FirebaseFirestore`, `FirebaseMessaging`, `FirebaseRemoteConfig` and `FirebaseStorage` facades 112 | 113 | ### Removed 114 | * Dropped support Laravel 5.8 and Lumen 5.8 115 | 116 | ## 2.4.0 - 2020-10-04 117 | 118 | ### Added 119 | * PHP `^8.0` is now an allowed (but untested) PHP version 120 | 121 | ## 2.3.1 - 2020-09-08 122 | 123 | (no changes, I just somehow mis-tagged 2.3.0 🙈) 124 | 125 | ## 2.3.0 - 2020-09-08 126 | 127 | ### Added 128 | * Added support for Laravel 8.x 129 | 130 | ## 2.2.0 - 2020-06-20 131 | 132 | ### Added 133 | * It is now possible to log HTTP requests and responses to the Firebase APIs to existing log channels. 134 | See the "logging" section in [`config/firebase.php`](config/firebase.php) for the configuration 135 | options and the [SDK Logging Documentation](https://firebase-php.readthedocs.io/en/5.5.0/setup.html#logging) 136 | for more information. 137 | ### Changed 138 | * The default branch of the GitHub repository has been renamed from `master` to `main` - 139 | if you're using `dev-master` as a version constraint in your `composer.json`, please 140 | update it to `dev-main`. 141 | 142 | ## 2.1.0 - 2020-05-27 143 | 144 | * Add config option to debug HTTP requests made directly from the SDK. It is disabled by 145 | default and can be enabled with the `FIREBASE_ENABLE_DEBUG=true` environment variable 146 | or by adding `'debug' => true` to `config/firebase.php`. 147 | 148 | ## 2.0.0 - 2020-04-01 149 | 150 | * Update `kreait/firebase` to `^5.0` 151 | 152 | ## 1.5.0 - 2020-02-29 153 | 154 | * Updated `kreait/firebase-php` to `^4.40.1` 155 | * Added support for Laravel/Lumen `^7.0` 156 | 157 | ## 1.4.0 - 2020-02-22 158 | 159 | * Updated `kreait/firebase-php` to `^4.40.0` 160 | * A relative path to a credentials file is now resolved with `base_path()` to address issues on Windows systems [#7](https://github.com/kreait/laravel-firebase/issues/7) 161 | 162 | ## 1.3.0 - 2020-01-15 163 | 164 | * Added a notice about not using the factory pattern described in the SDK documentation when using this package. 165 | (Although not a code change, adding it in the changelog to enhance visibility) 166 | * Added support for [Lumen](https://lumen.laravel.com/) 167 | * Updated `kreait/firebase-php` to `^4.38.1` 168 | 169 | ## 1.2.0 - 2019-10-26 170 | 171 | * Updated `kreait/firebase-php` to `^4.35.0` 172 | * Added Firestore to the Service Provider and as `FirebaseFirestore` facade 173 | 174 | ## 1.1.0 - 2019-09-19 175 | 176 | * Updated `kreait/firebase-php` to `^4.32.0` 177 | * Added Dynamic Links to the Service Provider and as `FirebaseDynamicLinks` facade 178 | * Added `FIREBASE_DYNAMIC_LINKS_DEFAULT_DOMAIN` as environment variable 179 | 180 | To update the package, please re-publish its configuration 181 | 182 | ```bash 183 | php artisan vendor:publish --provider="Kreait\Laravel\Firebase\ServiceProvider" --tag=config 184 | ``` 185 | 186 | or add the following section to `config/firebase.php`: 187 | 188 | ```php 189 | [ 194 | 'default_domain' => env('FIREBASE_DYNAMIC_LINKS_DEFAULT_DOMAIN') 195 | ], 196 | // ... 197 | ]; 198 | ``` 199 | 200 | ## 1.0.1 - 2019-08-19 201 | 202 | * Made clear that this package needs Laravel 5.8 or higher. 203 | * Updated `kreait/firebase-php` to `^4.30.1` 204 | * Required `illuminate/contracts` and `illuminate/support` 205 | 206 | ## 1.0.0 - 2019-08-17 207 | 208 | * Initial release 209 | -------------------------------------------------------------------------------- /config/firebase.php: -------------------------------------------------------------------------------- 1 | env('FIREBASE_PROJECT', 'app'), 13 | 14 | /* 15 | * ------------------------------------------------------------------------ 16 | * Firebase project configurations 17 | * ------------------------------------------------------------------------ 18 | */ 19 | 20 | 'projects' => [ 21 | 'app' => [ 22 | 23 | /* 24 | * ------------------------------------------------------------------------ 25 | * Credentials / Service Account 26 | * ------------------------------------------------------------------------ 27 | * 28 | * In order to access a Firebase project and its related services using a 29 | * server SDK, requests must be authenticated. For server-to-server 30 | * communication this is done with a Service Account. 31 | * 32 | * If you don't already have generated a Service Account, you can do so by 33 | * following the instructions from the official documentation pages at 34 | * 35 | * https://firebase.google.com/docs/admin/setup#initialize_the_sdk 36 | * 37 | * Once you have downloaded the Service Account JSON file, you can use it 38 | * to configure the package. 39 | * 40 | * If you don't provide credentials, the Firebase Admin SDK will try to 41 | * auto-discover them 42 | * 43 | * - by checking the environment variable FIREBASE_CREDENTIALS 44 | * - by checking the environment variable GOOGLE_APPLICATION_CREDENTIALS 45 | * - by trying to find Google's well known file 46 | * - by checking if the application is running on GCE/GCP 47 | * 48 | * If no credentials file can be found, an exception will be thrown the 49 | * first time you try to access a component of the Firebase Admin SDK. 50 | * 51 | */ 52 | 53 | 'credentials' => env('FIREBASE_CREDENTIALS', env('GOOGLE_APPLICATION_CREDENTIALS')), 54 | 55 | /* 56 | * ------------------------------------------------------------------------ 57 | * Firebase Auth Component 58 | * ------------------------------------------------------------------------ 59 | */ 60 | 61 | 'auth' => [ 62 | 'tenant_id' => env('FIREBASE_AUTH_TENANT_ID'), 63 | ], 64 | 65 | /* 66 | * ------------------------------------------------------------------------ 67 | * Firestore Component 68 | * ------------------------------------------------------------------------ 69 | */ 70 | 71 | 'firestore' => [ 72 | 73 | /* 74 | * If you want to access a Firestore database other than the default database, 75 | * enter its name here. 76 | * 77 | * By default, the Firestore client will connect to the `(default)` database. 78 | * 79 | * https://firebase.google.com/docs/firestore/manage-databases 80 | */ 81 | 82 | // 'database' => env('FIREBASE_FIRESTORE_DATABASE'), 83 | ], 84 | 85 | /* 86 | * ------------------------------------------------------------------------ 87 | * Firebase Realtime Database 88 | * ------------------------------------------------------------------------ 89 | */ 90 | 91 | 'database' => [ 92 | 93 | /* 94 | * In most of the cases the project ID defined in the credentials file 95 | * determines the URL of your project's Realtime Database. If the 96 | * connection to the Realtime Database fails, you can override 97 | * its URL with the value you see at 98 | * 99 | * https://console.firebase.google.com/u/1/project/_/database 100 | * 101 | * Please make sure that you use a full URL like, for example, 102 | * https://my-project-id.firebaseio.com 103 | */ 104 | 105 | 'url' => env('FIREBASE_DATABASE_URL'), 106 | 107 | /* 108 | * As a best practice, a service should have access to only the resources it needs. 109 | * To get more fine-grained control over the resources a Firebase app instance can access, 110 | * use a unique identifier in your Security Rules to represent your service. 111 | * 112 | * https://firebase.google.com/docs/database/admin/start#authenticate-with-limited-privileges 113 | */ 114 | 115 | // 'auth_variable_override' => [ 116 | // 'uid' => 'my-service-worker' 117 | // ], 118 | 119 | ], 120 | 121 | 'dynamic_links' => [ 122 | 123 | /* 124 | * Dynamic links can be built with any URL prefix registered on 125 | * 126 | * https://console.firebase.google.com/u/1/project/_/durablelinks/links/ 127 | * 128 | * You can define one of those domains as the default for new Dynamic 129 | * Links created within your project. 130 | * 131 | * The value must be a valid domain, for example, 132 | * https://example.page.link 133 | */ 134 | 135 | 'default_domain' => env('FIREBASE_DYNAMIC_LINKS_DEFAULT_DOMAIN'), 136 | ], 137 | 138 | /* 139 | * ------------------------------------------------------------------------ 140 | * Firebase Cloud Storage 141 | * ------------------------------------------------------------------------ 142 | */ 143 | 144 | 'storage' => [ 145 | 146 | /* 147 | * Your project's default storage bucket usually uses the project ID 148 | * as its name. If you have multiple storage buckets and want to 149 | * use another one as the default for your application, you can 150 | * override it here. 151 | */ 152 | 153 | 'default_bucket' => env('FIREBASE_STORAGE_DEFAULT_BUCKET'), 154 | 155 | ], 156 | 157 | /* 158 | * ------------------------------------------------------------------------ 159 | * Caching 160 | * ------------------------------------------------------------------------ 161 | * 162 | * The Firebase Admin SDK can cache some data returned from the Firebase 163 | * API, for example Google's public keys used to verify ID tokens. 164 | * 165 | */ 166 | 167 | 'cache_store' => env('FIREBASE_CACHE_STORE', 'file'), 168 | 169 | /* 170 | * ------------------------------------------------------------------------ 171 | * Logging 172 | * ------------------------------------------------------------------------ 173 | * 174 | * Enable logging of HTTP interaction for insights and/or debugging. 175 | * 176 | * Log channels are defined in config/logging.php 177 | * 178 | * Successful HTTP messages are logged with the log level 'info'. 179 | * Failed HTTP messages are logged with the log level 'notice'. 180 | * 181 | * Note: Using the same channel for simple and debug logs will result in 182 | * two entries per request and response. 183 | */ 184 | 185 | 'logging' => [ 186 | 'http_log_channel' => env('FIREBASE_HTTP_LOG_CHANNEL'), 187 | 'http_debug_log_channel' => env('FIREBASE_HTTP_DEBUG_LOG_CHANNEL'), 188 | ], 189 | 190 | /* 191 | * ------------------------------------------------------------------------ 192 | * HTTP Client Options 193 | * ------------------------------------------------------------------------ 194 | * 195 | * Behavior of the HTTP Client performing the API requests 196 | */ 197 | 198 | 'http_client_options' => [ 199 | 200 | /* 201 | * Use a proxy that all API requests should be passed through. 202 | * (default: none) 203 | */ 204 | 205 | 'proxy' => env('FIREBASE_HTTP_CLIENT_PROXY'), 206 | 207 | /* 208 | * Set the maximum amount of seconds (float) that can pass before 209 | * a request is considered timed out 210 | * 211 | * The default time out can be reviewed at 212 | * https://github.com/kreait/firebase-php/blob/6.x/src/Firebase/Http/HttpClientOptions.php 213 | */ 214 | 215 | 'timeout' => env('FIREBASE_HTTP_CLIENT_TIMEOUT'), 216 | 217 | 'guzzle_middlewares' => [], 218 | ], 219 | ], 220 | ], 221 | ]; 222 | --------------------------------------------------------------------------------