kreait/laravel-firebase
Laravel integration for the Firebase PHP Admin SDK. Configure via FIREBASE_ env vars using a service account JSON or array credentials, then access Firebase services in your app. Supports multiple Firebase projects and common Laravel workflows.
Firebase Integration as a Core Feature:
Roadmap Priorities:
Use Cases:
Cost Optimization:
GOOGLE_APPLICATION_CREDENTIALS) to avoid per-environment setup.Security:
.env for credentials (never hardcoded) and restrict IAM roles to least privilege.kreait/firebase-php SDK (e.g., experimental APIs).kreait/firebase-php directly.*"This package lets us integrate Firebase’s powerful backend services (auth, real-time data, storage) into our Laravel app with minimal dev effort. It’s like having Google’s infrastructure team on call—without the ops overhead.
- Why? Firebase handles scaling, security, and compliance for us (e.g., GDPR, HIPAA via Google’s tools). We avoid building and maintaining these systems in-house.
- ROI: Faster time-to-market for features like user auth, live updates, or file storage. Example: Launch a chat app in weeks, not months.
- Cost: Pay-as-you-go for Firebase usage, with no upfront server costs. The package itself is free (MIT license).
- Risk Mitigation: Uses a mature, widely adopted SDK (1M+ monthly downloads) with Laravel-native abstractions.
Ask: Approve budget for Firebase services and allocate 1–2 dev days to integrate this package. We’ll start with Auth + Firestore for MVP, then expand."*
*"This is a drop-in Laravel package for Firebase’s Admin SDK, solving:
- Boilerplate: No manual SDK initialization—just
composer requireandconfig/firebase.php.- Multi-Project Support: Manage dev/staging/prod Firebase projects via config (critical for CI/CD).
- Security: Built-in AppCheck, token caching, and IAM-friendly credential handling.
- Observability: Log Firebase HTTP requests to Laravel’s logging channels.
Key Features:
- Auth: User management, custom tokens, OAuth.
- Firestore/Realtime DB: Real-time sync for live apps.
- Storage: File uploads with signed URLs.
- Messaging: Push notifications via FCM.
- Multi-Tenancy: Tenant-aware Firebase projects (e.g.,
FIREBASE_AUTH_TENANT_ID).Implementation Plan:
- Week 1: Set up Firebase projects + credentials (
.envor config array).- Week 2: Integrate Auth (e.g.,
Firebase::auth()->createCustomToken()).- Week 3: Add Firestore for real-time data (e.g.,
Firebase::firestore()->collection('users')).- Ongoing: Expand to Storage/Messaging as needed.
Dependencies:
- PHP 8.3+, Laravel 10+ (or newer).
- Google Cloud project with enabled Firebase services.
Alternatives Considered:
- Custom SDK wrapper: More work, less maintainable.
- Direct
kreait/firebase-php: Lacks Laravel integrations (facades, config).Next Steps:
- Approve Firebase setup (IAM roles, billing).
- Allocate time for integration (prioritize Auth + Firestore first).
- Monitor costs via Google Cloud Console."*
*"Here’s how to get started in 10 minutes:
Install:
composer require kreait/laravel-firebase php artisan vendor:publish --provider="Kreait\Laravel\Firebase\ServiceProvider" --tag=configConfigure:
- Add Firebase credentials to
.env(e.g.,FIREBASE_CREDENTIALS=storage/app/firebase.json).- Set
FIREBASE_DATABASE_URL(e.g.,https://your-project.firebaseio.com).Use It:
- Auth:
$user = Firebase::auth()->createUser(['email' => 'user@example.com', 'password' => 'secret']);- Firestore:
$doc = Firebase::firestore()->collection('posts')->document('1')->set(['title' => 'Hello']);- Multi-Project:
$stagingAuth = Firebase::project('staging')->auth();Pro Tips:
- Debugging: Enable HTTP logging in
config/firebase.php(http_debug_log_channel).- Security: Use
GOOGLE_APPLICATION_CREDENTIALSfor production (never commit JSON files).- Performance: Cache tokens with Symfony Cache (
'cache' => 'array'in config).Docs:
Need Help? Slack the team or check the GitHub Issues."*
How can I help you explore Laravel packages today?