PHPackages                             cmosh/laravel-firebase - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. cmosh/laravel-firebase

ActiveLibrary

cmosh/laravel-firebase
======================

A Firebase port for Laravel (4.2+)

0.4(10y ago)043PHPPHP &gt;=5.4.0

Since Jun 14Pushed 8y ago1 watchersCompare

[ Source](https://github.com/cmosh/laravel-firebase)[ Packagist](https://packagist.org/packages/cmosh/laravel-firebase)[ RSS](/packages/cmosh-laravel-firebase/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

laravel-firebase
================

[](#laravel-firebase)

A Firebase port for Laravel (4.2+)

\##Configuration

Install via composer. If you have `minimum-stability` set to `stable`, you should add a `@beta` or `@dev` in order to use the `php-jwt` library (a dependency managed by firebase for generating JSON web token).

Add the following line to your `composer.json` and run composer update:

```
{
  "require": {
    "cmosh/laravel-firebase": "dev-master"
  }
}

```

Then add the service providers and facades to `config/app.php`

```
'Cmosh\LaravelFirebase\LaravelFirebaseServiceProvider',

```

...

```
'Firebase'		  => 'Cmosh\LaravelFirebase\LaravelFirebaseFacade'

```

Access Tokens
-------------

[](#access-tokens)

Finally, you should configure your firebase connection in the `config/database.php` array. There are two ways you can define this:

\####Simple Access Token

```
'firebase' => array(
	'host'		=> 'https://.firebaseio.com/',
	'token'		=> '',
	'timeout'	=> 10,
	'sync'		=> false,			// OPTIONAL: auto-sync all Eloquent models with Firebase?
)
```

\####Advanced: Request a JWT

This accepts any of the standard options allowed by the firebase [security rules](https://www.firebase.com/docs/security/security-rules.html) and will generate a JSON Web Token for more granular authentication (subject to auth security rules and expirations).

```
'firebase' => array(
	'host'		=> 'https://servicerunner.firebaseio.com/',
	'token'		=> [
		'secret'	=> '',
		'options'	=> [
			'auth'	=> [
				'email' => 'example@yoursite.com'
			]
		],
		'data'		=> []
	],
	'timeout'	=> 10,
	'sync'		=> false,			// OPTIONAL: auto-sync all Eloquent models with Firebase?
)
```

The **FirebaseClient** instance is loaded into the IoC container as a singleton, containing a Guzzle instance used to interact with Firebase.

Getting Started
---------------

[](#getting-started)

Making simple get requests:

```
// Returns: (Array) of data items
Firebase::get('/my/path');

// Returns: (\Illuminate\Database\Eloquent\Collection) Eloquent collection of Eloquent models
Firebase::get('/my/path', 'ValidEloquentModelClass');

// Returns: (\Illuminate\Database\Eloquent\Model) Single Eloquent model
// Conditions: $SomeModelInstance must inherit from Eloquent at some point, and have a (id, _id, or $id) property
Firebase::get($SomeModelInstance);

// Returns: (Array) Firebase response
Firebase::set('/my/path', $data);

// Returns: (Array) Firebase response
Firebase::push('/my/path', $data);

// Returns: (Array) Firebase response
Firebase::delete('/my/path');
```

Model Syncing
-------------

[](#model-syncing)

By default this package will keep your Eloquent models in sync with Firebase. That means that whenever `eloquent.updated: *` is fired, the model will be pushed to Firebase.

This package will automatically look for 'id', '\_id', and '$id' variables on the model so that Firebase paths are normalized like so:

```
// Eloquent model: User
// Firebase location: /users/{user::id}

$User = new User(['name' => 'Julian']);

$User->save();	// Pushed to firebase

$Copy = Firebase::get('/users/'.$User->id, 'User'); 	// === copy of $User
$Copy = Firebase::get($User);							// === copy of $User
```

To disable this, please ensure `'sync' => false` in your database.connections.firebase configuration array.

This works with any package that overwrites the default Eloquent model SO LONG AS it is configured to fire the appropriate `saved` and `updated` events. At the moment it is tested with the base `Illuminate...Model` as well as the [Jenssegers MongoDB Eloquent Model](https://github.com/jenssegers/laravel-mongodb)

\####Syncing Models Individually

If you want to add a whitelist of properties to push to firebase automatically whenever a model is **updated**, you can do so by adding a whitelist of properties to any supported model.

This action happens regardless of the (automatic) `sync` property in your configuration array. If the `$firebase` whitelist array is found, then the fields contained will be posted on every update event.

```
class User extends Eloquent {
	...
	public $firebase = ['public_property','name','created'];	// These properties are pushed to firebase every time the model is updated
}
```

\##Advanced Use

\#####Create a token manually

```
$FirebaseTokenGenerator = new Cmosh\LaravelFirebase\FirebaseToken(FIREBASE_SECRET);
$Firebase = App::make('firebase');

$token = $FirebaseTokenGenerator->create($data, $options);

$Firebase->setToken($token);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~99 days

Recently: every ~124 days

Total

6

Last Release

3848d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/714d9999ef83f989256e8149adbb0ea821c654ed87584df4b44dd70047ff5cbd?d=identicon)[cmosh](/maintainers/cmosh)

---

Top Contributors

[![j42](https://avatars.githubusercontent.com/u/5133586?v=4)](https://github.com/j42 "j42 (92 commits)")[![cmosh](https://avatars.githubusercontent.com/u/11471798?v=4)](https://github.com/cmosh "cmosh (3 commits)")[![albertcat](https://avatars.githubusercontent.com/u/1935397?v=4)](https://github.com/albertcat "albertcat (1 commits)")[![johnstontrav](https://avatars.githubusercontent.com/u/7200330?v=4)](https://github.com/johnstontrav "johnstontrav (1 commits)")

### Embed Badge

![Health badge](/badges/cmosh-laravel-firebase/health.svg)

```
[![Health](https://phpackages.com/badges/cmosh-laravel-firebase/health.svg)](https://phpackages.com/packages/cmosh-laravel-firebase)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M672](/packages/laravel-socialite)[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k17](/packages/civicrm-civicrm-core)[opentok/opentok

OpenTok is a platform for creating real time streaming video applications, created by TokBox.

1413.0M10](/packages/opentok-opentok)[pusher/pusher-push-notifications

562.5M9](/packages/pusher-pusher-push-notifications)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
