- How do I install kreait/laravel-firebase in a Laravel 13 project?
- Run `composer require kreait/laravel-firebase` in your project root. The package auto-discovers Laravel and registers the service provider. No manual configuration is needed beyond setting up Firebase credentials in `.env`. Ensure PHP 8.3+ is used, as the package requires it.
- Can I use this package with Laravel 10 or older versions?
- The latest version supports Laravel 11–13 only. For Laravel 10, use `kreait/laravel-firebase:^6.2.0`, but this drops PHP 8.2 support. Check the [release notes](https://github.com/beste/laravel-firebase/releases) for version-specific compatibility.
- How do I configure Firebase credentials for multiple projects?
- Use the `FIREBASE_CREDENTIALS_<project_name>` environment variables or define them in `config/firebase.php` under the `projects` key. Access specific projects via `Firebase::project('project_name')->auth()` or `Firebase::project('project_name')->storage()`.
- What’s the best way to handle Firebase credentials in CI/CD (e.g., GitHub Actions)?
- Store the JSON credential file in a secrets manager (e.g., GitHub Secrets) and reference it via `FIREBASE_CREDENTIALS=/path/to/file.json` in your CI environment. Avoid hardcoding credentials in `.env` files for security.
- How do I mock Firebase services in PHPUnit tests?
- Use Laravel’s `Mockery` or the `kreait/firebase-php` mocking utilities. Bind a mock instance to the container in your test setup: `$this->app->instance('firebase', Mockery::mock('overload', Firebase::class));`. Test specific services like `auth()` or `storage()` separately.
- Does this package support Firebase Realtime Database or only Firestore?
- The package supports both Realtime Database and Firestore through the underlying `kreait/firebase-php` SDK. Access them via `Firebase::project()->database()` or `Firebase::project()->firestore()`, respectively. Check the [SDK docs](https://firebase-php.readthedocs.io/) for feature parity.
- What are the performance implications of using Firebase Storage with this package?
- Firebase Storage operations are subject to Firebase’s rate limits (e.g., 5MB/s uploads for Spark plan). For high-throughput apps, implement retries with exponential backoff using Guzzle middleware or Laravel’s `retry` helper. Monitor usage via Firebase Console.
- How do I switch from the deprecated `FirebaseAuth` facade to the new `Firebase::auth()` syntax?
- Replace `FirebaseAuth::createUser()` with `Firebase::auth()->createUser()`. The package deprecates old facades in favor of a unified `Firebase` facade. Run `php artisan vendor:publish --tag=config` to update your config if needed.
- Can I use this package with Laravel Queues for async Firebase operations?
- Yes, but ensure statelessness by avoiding persistent connections (e.g., Firestore listeners). Use `stateless: true` in your queue worker or configure the Firebase SDK to avoid caching tokens. Test in a distributed environment to validate behavior.
- Are there alternatives to kreait/laravel-firebase for Firebase + Laravel integration?
- Other options include `spatie/laravel-firebase` (community-driven, less maintained) or direct `kreait/firebase-php` integration. However, `kreait/laravel-firebase` offers tighter Laravel integration (container, facades, multi-project support) and is actively maintained by the `beste` org.