PHPackages                             zend\_firebase/zend\_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. [HTTP &amp; Networking](/categories/http)
4. /
5. zend\_firebase/zend\_firebase

ActiveLibrary[HTTP &amp; Networking](/categories/http)

zend\_firebase/zend\_firebase
=============================

php library for manage all rest and stream operations of firebase

v0.4.4(9y ago)42953[1 issues](https://github.com/Samuel18/zend_Firebase/issues)BSD-3-ClausePHPPHP &gt;=7.0

Since Oct 20Pushed 8y ago4 watchersCompare

[ Source](https://github.com/Samuel18/zend_Firebase)[ Packagist](https://packagist.org/packages/zend_firebase/zend_firebase)[ Docs](http://www.samuelventimiglia.it/)[ RSS](/packages/zend-firebase-zend-firebase/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (6)Versions (30)Used By (0)

PHP7 Firebase REST and STREAM Client
====================================

[](#php7-firebase-rest-and-stream-client)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/79e4930b1453e25f0365a15cd34663fc6bd6783358bb3b0d0b0731c514f0aaf3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f53616d75656c31382f7a656e645f46697265626173652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Samuel18/zend_Firebase/?branch=master)[![Travis CI Build Status](https://camo.githubusercontent.com/aa308dda0f836c14011723ffe00a413f6d9099ebae9fb1637178258da6adc8af/68747470733a2f2f7472617669732d63692e6f72672f73616d75656c32306d69676c69612f7a656e645f46697265626173652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Samuel18/zend_Firebase)[![codecov](https://camo.githubusercontent.com/923ab0ef81968cf26858be4e41ae59ea5c7b359acd71481c19b292f6351c4630/68747470733a2f2f636f6465636f762e696f2f67682f73616d75656c32306d69676c69612f7a656e645f46697265626173652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/samuel20miglia/zend_Firebase)

[![PHP 7 ready](https://camo.githubusercontent.com/6cd2315e0a689a65ca6f1acf8aad64e4c08c43b387c41e9a993983151e33f068/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f73616d75656c32306d69676c69612f7a656e645f46697265626173652f62616467652e737667)](https://travis-ci.org/Samuel18/zend_Firebase)[![Total Downloads](https://camo.githubusercontent.com/74b48c93a8e98d39d28c0f240c0ceb7b191d4476bf72bb359934e61f30382ab3/68747470733a2f2f706f7365722e707567782e6f72672f7a656e645f66697265626173652f7a656e645f66697265626173652f646f776e6c6f616473)](https://packagist.org/packages/zend_firebase/zend_firebase)[![Latest Stable Version](https://camo.githubusercontent.com/b29407183c11cba6e54daa4b9c55c464aef5d21432bdcf2a898427e501a7f665/68747470733a2f2f706f7365722e707567782e6f72672f7a656e645f66697265626173652f7a656e645f66697265626173652f762f737461626c65)](https://packagist.org/packages/zend_firebase/zend_firebase)[![License](https://camo.githubusercontent.com/b768b3b322e5972e80b2cc1ee8d8a26b3d833fac2a263b01104d55a5a32060ac/68747470733a2f2f706f7365722e707567782e6f72672f7a656e645f66697265626173652f7a656e645f66697265626173652f6c6963656e7365)](https://packagist.org/packages/zend_firebase/zend_firebase)

Based on the [Firebase REST API](https://firebase.google.com/docs/reference/rest/database/).

Available on [Packagist](https://packagist.org/packages/zend_firebase/zend_firebase).

\###Prerequisites

- PHP &gt;= 7.0
- Firebase Active Account
- Composer (recommended, not required)

### Adding Firebase PHP to your project using Composer

[](#adding-firebase-php-to-your-project-using-composer)

```
cd

composer require zend_firebase/zend_firebase dev-master
```

More info about Composer at [getcomposer.org](http://getcomposer.org).

### Simple Example of Usage

[](#simple-example-of-usage)

```
use ZendFirebase\Firebase, ZendFirebase\Authentication\FirebaseAuth;

$auth = new FirebaseAuth();

$auth->setBaseURI('https://your_url_from_firebase/');
$auth->setServertoken('your_firebase_token');

/* ---  EXAMPLE OF DATA TO POST REMEMBER ALL DATA MUST BE ARRAY --- */
$test = array(
    "name" => "TEST",
    "id" => 5245,
    "text" => "hello TEST 5245",
    "status" => "sended"
);

/* --- CREATE NEW OBJECT AND PASS CREDENTIAL --- */
$firebase = new Firebase($auth);

/* --- CHOOCE THE OPERATION (SAME NAME OF FIREBASE DOCS)  --- */
$firebase->post('path', $test);
```

Inside folder "examples" you can find some another simple complete example for library usage. Go to next step!

### Response Usage

[](#response-usage)

```
/* --- FIREBASE DATA FROM REALTIME DB IS AN ARRAY  --- */
$firebase->getFirebaseData(); 	// getOperation(); // getStatus(); 	// getLastIdStored();
```

Go to next step!

---

### Supported Commands

[](#supported-commands)

```
/* --- STORING DATA --- */
$firebase->post('path', $test,$options);
/* --- OVERRIDE DATA --- */
$firebase->put('path', $test,$options);
/* --- UPDATE DATA --- */
$firebase->patch('path', $test,$options);
/* --- RETRIEVE DATA --- */
$firebase->get('path',$options);
/* --- DELETE DATA --- */
$firebase->delete('path',$options);
/* --- RETRIEVE RULES --- */
$firebase->getRules('.settings/rules',$options);
```

Go to next step!

---

### Manage rules via REST

[](#manage-rules-via-rest)

\####Read

```
require_once __DIR__ . '/vendor/autoload.php';
use ZendFirebase\Firebase;
use ZendFirebase\Authentication\FirebaseAuth;

$auth = new FirebaseAuth();

$auth->setBaseURI(/* complete with your firebase url */);
$auth->setServertoken(/* complete with your firebase token */);

$path = '.settings/rules'; // path of rules

$firebase = new Firebase($auth);

/* call function */
$firebase->getRules($path);

/* show rules! */
print_r($firebase->getFirebaseData());
```

\####Write

```
require_once __DIR__ . '/vendor/autoload.php';
use ZendFirebase\Firebase;
use ZendFirebase\Authentication\FirebaseAuth;

$auth = new FirebaseAuth();

$auth->setBaseURI(/* complete with your firebase url */);
$auth->setServertoken(/* complete with your firebase token */);

$path = '.settings/rules'; // path of rules

$firebase = new Firebase($auth);

$rules =[
     "rules" => [
         ".read" => true,
         ".write" => "!data.exists() || !newData.exists()"
         ]
 ];

/* call function to write */
$firebase->writeRules($path,$rules);

/* show result! */
print_r($firebase->getFirebaseData());
```

now you are able to manage rules. Go to next step!

---

### Rest Stream API

[](#rest-stream-api)

Create a new file your\_file\_name.php .

Inside this new file insert the following code :

```
use ZendFirebase\Firebase, ZendFirebase\Authentication\FirebaseAuth;

$auth = new FirebaseAuth();

$auth->setBaseURI('https://your_url_from_firebase/');
$auth->setServertoken('your_firebase_token');

/* --- CREATE NEW OBJECT AND PASS CREDENTIAL --- */
$firebase = new Firebase($auth);

$options = []; // container options as type array

$callback = 'callbackFunction'; // name of callback function as type string

function callbackFunction(...$params){
    // all code needed
}

$print = true;

/* --- SET PATH,
	   NAME OF FOLDER WHERE STORE LOGS,
	   MILLISECONDS OF DELAY BETWEEN NEW REQUEST (not required, default 5000),
	   CALLBACK FUNCTION,
	   ARRAY OPTIONS (not required, default []),
	   PRINT (not required, default TRUE) --- */
$firebase->startStream('path', 'logs/', 5000, $callback, $options, $print);
```

Now for run listener open terminal and run you file with command :

```
php your_file_name.php
```

This method start listener and write log file of changes.

---

### PHPUnit Tests

[](#phpunit-tests)

All the unit tests are found in the "/tests" directory. Due to the usage of an interface, the tests must run in isolation.

Project Configuration it's just setted for doing all tests with the simple command :

```
cd

phpunit
```

If you want to run a single test, just run :

```
cd

phpunit name_and_path_of_the_file_that_you_want_to_test.php
```

#### BSD 3-Clause License

[](#bsd-3-clause-license)

[READ BSD LICENSE](LICENSE)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.3% 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 ~6 days

Recently: every ~1 days

Total

28

Last Release

3325d ago

PHP version history (2 changes)v0.1.0PHP &gt;=7.0

v0.2.2PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/99b390f8ddc4ef0214fc4131a685b15c370d691dad8262aa2bee822ce44207bd?d=identicon)[samuel20miglia](/maintainers/samuel20miglia)

---

Top Contributors

[![samuel20miglia](https://avatars.githubusercontent.com/u/9152043?v=4)](https://github.com/samuel20miglia "samuel20miglia (87 commits)")[![DavideBiasin](https://avatars.githubusercontent.com/u/16794123?v=4)](https://github.com/DavideBiasin "DavideBiasin (17 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (10 commits)")

---

Tags

composerfirebasegooglelibraryphpphp7streaming-apirestwrapperfirebaseREST APIphp firebasegoogle-firebasefirebase libraryphp library firebasephp7 firebaseREST firebaseREST php7 firebaseSTREAM REST php7 firebaseSTREAM REST firebasestream firebasefirebase stream apifirebase php librarygoogle php firebase library

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[ktamas77/firebase-php

Firebase PHP Client

7881.8M10](/packages/ktamas77-firebase-php)[eelkevdbos/firebase-php

Firebase php wrapper for REST API

7728.8k](/packages/eelkevdbos-firebase-php)[huaweicloud/huaweicloud-sdk-php

Huawei Cloud SDK for PHP

1829.2k2](/packages/huaweicloud-huaweicloud-sdk-php)

PHPackages © 2026

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