1. Go to this page and download the library: Download j42/laravel-firebase library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// 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');
// 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
class User extends Eloquent {
...
public $firebase = ['public_property','name','created']; // These properties are pushed to firebase every time the model is updated
}