- What Laravel and PHP versions does kreait/laravel-firebase support?
- The package requires Laravel 11+ and PHP 8.3+. If you're using an older version, you’ll need to upgrade or explore alternatives like older package releases, though support for Laravel <11 is no longer provided.
- How do I configure Firebase credentials for multiple projects?
- Define each project in the `config/firebase.php` file under the `projects` key, assigning unique names (e.g., `project_a`, `project_b`). Use environment variables or JSON files for credentials, and switch projects via `Firebase::project('project_name')`.
- Can I use environment variables instead of a JSON file for Firebase credentials?
- Yes. The package supports credentials via environment variables like `FIREBASE_CREDENTIALS_JSON`. You can also use arrays or split credentials into separate variables (e.g., `FIREBASE_CLIENT_EMAIL`, `FIREBASE_PRIVATE_KEY`) for better security in shared environments.
- Does this package support Firebase Authentication (e.g., creating users, managing sessions)?
- Yes. Access Firebase Auth via `Firebase::auth()` and use methods like `createUser()`, `getUser()`, or `revokeRefreshTokens()`. The package provides a Laravel-friendly wrapper around the underlying Firebase Admin SDK’s Auth service.
- How do I handle errors like FirebaseAuthException in Laravel?
- Catch exceptions from Firebase methods (e.g., `try-catch (FirebaseAuthException $e)`) and convert them to Laravel exceptions if needed. The package doesn’t auto-map errors, so you’ll need to handle them manually or extend the package’s exception handling.
- Is there built-in support for Firestore offline persistence or batch writes?
- No, the package exposes the raw Firestore SDK methods, so offline persistence or batch writes require manual implementation using the underlying `FirestoreDatabase` instance. Check the [Firebase PHP SDK docs](https://firebase-php.readthedocs.io/) for details.
- Can I use this package in a serverless environment (e.g., AWS Lambda, Vercel)?
- Yes, but ensure your credentials are securely stored (e.g., AWS Secrets Manager or environment variables). The package supports array-based credentials, which are easier to manage in serverless deployments than JSON files.
- How do I test Firebase interactions in Laravel unit tests?
- Mock the Firebase services using tools like Mockery or PHPUnit’s `createMock()`. For example, mock `Auth` or `FirestoreDatabase` and inject them into your service layer. Avoid hitting real Firebase APIs in tests to prevent costs or rate limits.
- Does the package support Firebase Storage (e.g., uploading/download files)?
- Yes. Access Storage via `Firebase::storage()` and use methods like `upload()`, `download()`, or `delete()`. The package provides a facade for the underlying `StorageBucket` service, supporting all standard Firebase Storage operations.
- What are the alternatives to kreait/laravel-firebase for Firebase-Laravel integration?
- Alternatives include raw `kreait/firebase-php` (no Laravel integration) or community packages like `spatie/laravel-firebase`. However, `kreait/laravel-firebase` is the most actively maintained and Laravel-idiomatic option, with built-in support for multiple projects and Laravel’s service container.