- How do I install ktamas77/firebase-php in a Laravel project?
- Use Composer to install the package with `composer require ktamas77/firebase-php`. No additional Laravel-specific setup is required, though you may want to configure it via a Service Provider or Facade for cleaner integration.
- Does this package support Firebase Authentication alongside Laravel’s built-in auth?
- Yes, the package supports Firebase Auth tokens and service accounts. You can use it alongside Laravel’s auth system, but you’ll need to manage token handling (e.g., storing tokens in sessions or using Laravel Sanctum for hybrid flows).
- Can I use this for Firestore instead of Realtime Database?
- No, this package is specifically for Firebase Realtime Database via REST API. For Firestore, consider alternatives like Google’s official PHP client or a dedicated Firestore package, as the APIs and data models differ significantly.
- What Laravel versions are supported by ktamas77/firebase-php?
- The package is framework-agnostic but requires PHP 8.x+. It works seamlessly with Laravel 9+ and Laravel 10, as it doesn’t rely on Laravel-specific features beyond basic PHP compatibility.
- How do I secure Firebase service account credentials in Laravel?
- Store credentials in Laravel’s `.env` file (e.g., `FIREBASE_CREDENTIALS`) and load them via `config('services.firebase')`. Never hardcode keys in your application code, and restrict Firebase rules to least-privilege access.
- Is this package suitable for production with high traffic?
- Yes, but monitor Firebase’s free tier quotas (e.g., 50K daily reads/writes). For high traffic, implement caching (e.g., Redis) for frequent queries and consider sharding data or upgrading Firebase plans.
- Can I use this package for real-time updates like chat apps?
- This package uses REST API calls, so it’s not ideal for true real-time updates (e.g., WebSocket-like pub/sub). For chat apps, use Firebase’s JavaScript SDK on the client side or explore WebSocket alternatives like Laravel Echo.
- How do I test Firebase operations in Laravel’s testing environment?
- Mock Firebase responses using PHPUnit’s `createMock()` or Laravel’s `Mockery`. Test CRUD operations by intercepting HTTP calls to Firebase’s REST API endpoints, ensuring your logic handles success/failure states correctly.
- Are there alternatives to ktamas77/firebase-php for Laravel?
- For Firebase Realtime Database, alternatives include Google’s official PHP client or custom REST wrappers. For Firestore, consider `google/cloud-firestore` or `spatie/firestore`. Evaluate based on your need for simplicity vs. full Firebase service support.
- How do I handle Firebase token expiration in Laravel sessions?
- Refresh tokens before they expire by checking their `expiration_time` and calling Firebase’s `refreshToken` endpoint. Store the new token in the session or use Laravel’s cache to avoid frequent refreshes. Implement middleware to validate tokens on protected routes.