{"id":15046085,"url":"https://github.com/samuel20miglia/zend_firebase","last_synced_at":"2025-07-06T07:07:39.270Z","repository":{"id":57089830,"uuid":"71248574","full_name":"samuel20miglia/zend_Firebase","owner":"samuel20miglia","description":"PHP library for rest and stream Firebase, php7 firebase","archived":false,"fork":false,"pushed_at":"2017-12-13T09:05:27.000Z","size":724,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-07T10:11:30.595Z","etag":null,"topics":["composer","firebase","google","library","php","php7","streaming-api"],"latest_commit_sha":null,"homepage":"https://samuel20miglia.github.io/zend_Firebase/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samuel20miglia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-18T13:00:06.000Z","updated_at":"2018-01-22T18:47:46.000Z","dependencies_parsed_at":"2022-08-20T15:30:15.914Z","dependency_job_id":null,"html_url":"https://github.com/samuel20miglia/zend_Firebase","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/samuel20miglia/zend_Firebase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuel20miglia%2Fzend_Firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuel20miglia%2Fzend_Firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuel20miglia%2Fzend_Firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuel20miglia%2Fzend_Firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuel20miglia","download_url":"https://codeload.github.com/samuel20miglia/zend_Firebase/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuel20miglia%2Fzend_Firebase/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263861949,"owners_count":23521355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","firebase","google","library","php","php7","streaming-api"],"created_at":"2024-09-24T20:52:41.245Z","updated_at":"2025-07-06T07:07:39.254Z","avatar_url":"https://github.com/samuel20miglia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP7 Firebase REST and STREAM Client\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Samuel18/zend_Firebase/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Samuel18/zend_Firebase/?branch=master)\n[![Travis CI Build Status](https://travis-ci.org/samuel20miglia/zend_Firebase.svg?branch=master)](https://travis-ci.org/Samuel18/zend_Firebase)\n[![codecov](https://codecov.io/gh/samuel20miglia/zend_Firebase/branch/master/graph/badge.svg)](https://codecov.io/gh/samuel20miglia/zend_Firebase)\n\n[![PHP 7 ready](http://php7ready.timesplinter.ch/samuel20miglia/zend_Firebase/badge.svg)](https://travis-ci.org/Samuel18/zend_Firebase)\n[![Total Downloads](https://poser.pugx.org/zend_firebase/zend_firebase/downloads)](https://packagist.org/packages/zend_firebase/zend_firebase)\n[![Latest Stable Version](https://poser.pugx.org/zend_firebase/zend_firebase/v/stable)](https://packagist.org/packages/zend_firebase/zend_firebase)\n[![License](https://poser.pugx.org/zend_firebase/zend_firebase/license)](https://packagist.org/packages/zend_firebase/zend_firebase)\n\nBased on the [Firebase REST API](https://firebase.google.com/docs/reference/rest/database/).\n\nAvailable on [Packagist](https://packagist.org/packages/zend_firebase/zend_firebase).\n\n###Prerequisites\n- PHP \u003e= 7.0\n- Firebase Active Account\n- Composer (recommended, not required)\n\n### Adding Firebase PHP to your project using Composer\n\n```bash\ncd \u003cyour_project\u003e\n\ncomposer require zend_firebase/zend_firebase dev-master\n```\n\nMore info about Composer at [getcomposer.org](http://getcomposer.org).\n\n### Simple Example of Usage\n```php\nuse ZendFirebase\\Firebase, ZendFirebase\\Authentication\\FirebaseAuth;\n\n$auth = new FirebaseAuth();\n\n$auth-\u003esetBaseURI('https://your_url_from_firebase/');\n$auth-\u003esetServertoken('your_firebase_token');\n\n/* ---  EXAMPLE OF DATA TO POST REMEMBER ALL DATA MUST BE ARRAY --- */\n$test = array(\n    \"name\" =\u003e \"TEST\",\n    \"id\" =\u003e 5245,\n    \"text\" =\u003e \"hello TEST 5245\",\n    \"status\" =\u003e \"sended\"\n);\n\n/* --- CREATE NEW OBJECT AND PASS CREDENTIAL --- */\n$firebase = new Firebase($auth);\n\n\n/* --- CHOOCE THE OPERATION (SAME NAME OF FIREBASE DOCS)  --- */\n$firebase-\u003epost('path', $test);\n```\nInside folder \"examples\" you can find some another simple complete example for library usage. Go to next step!\n\n### Response Usage\n```php\n\n/* --- FIREBASE DATA FROM REALTIME DB IS AN ARRAY  --- */\n$firebase-\u003egetFirebaseData(); \t// \u003c- array, data returning from Firebase\necho $firebase-\u003egetOperation(); // \u003c- string, operation just made (for example: GET or POST etc...)\necho $firebase-\u003egetStatus(); \t// \u003c- numeric, status of request (for example: 200 or 400 or 500)\n```\nGo to next step!\n\n### Get Last Auto-Increment Id generate from Firebase after 'post' command\n```php\n\n/* --- GET LAST AUTO-INCREMENT ID INSERED AFTER POST COMMAND --- */\n$firebase-\u003egetLastIdStored();\n\n```\nGo to next step!\n\n\u003chr/\u003e\n\n### Supported Commands\n```php\n\n/* --- STORING DATA --- */\n$firebase-\u003epost('path', $test,$options);\n/* --- OVERRIDE DATA --- */\n$firebase-\u003eput('path', $test,$options);\n/* --- UPDATE DATA --- */\n$firebase-\u003epatch('path', $test,$options);\n/* --- RETRIEVE DATA --- */\n$firebase-\u003eget('path',$options);\n/* --- DELETE DATA --- */\n$firebase-\u003edelete('path',$options);\n/* --- RETRIEVE RULES --- */\n$firebase-\u003egetRules('.settings/rules',$options);\n```\nGo to next step!\n\n\u003chr/\u003e\n\n### Manage rules via REST\n\n####Read\n\n```php\n\nrequire_once __DIR__ . '/vendor/autoload.php';\nuse ZendFirebase\\Firebase;\nuse ZendFirebase\\Authentication\\FirebaseAuth;\n\n$auth = new FirebaseAuth();\n\n$auth-\u003esetBaseURI(/* complete with your firebase url */);\n$auth-\u003esetServertoken(/* complete with your firebase token */);\n\n$path = '.settings/rules'; // path of rules\n\n$firebase = new Firebase($auth);\n\n\n/* call function */\n$firebase-\u003egetRules($path);\n\n/* show rules! */\nprint_r($firebase-\u003egetFirebaseData());\n```\n\n####Write\n\n```php\n\nrequire_once __DIR__ . '/vendor/autoload.php';\nuse ZendFirebase\\Firebase;\nuse ZendFirebase\\Authentication\\FirebaseAuth;\n\n$auth = new FirebaseAuth();\n\n$auth-\u003esetBaseURI(/* complete with your firebase url */);\n$auth-\u003esetServertoken(/* complete with your firebase token */);\n\n$path = '.settings/rules'; // path of rules\n\n$firebase = new Firebase($auth);\n\n$rules =[\n     \"rules\" =\u003e [\n         \".read\" =\u003e true,\n         \".write\" =\u003e \"!data.exists() || !newData.exists()\"\n         ]\n ];\n \n/* call function to write */\n$firebase-\u003ewriteRules($path,$rules);\n\n/* show result! */\nprint_r($firebase-\u003egetFirebaseData());\n```\nnow you are able to manage rules. Go to next step!\n\n\u003chr/\u003e\n\n### Rest Stream API\n\nCreate a new file your_file_name.php .\n\nInside this new file insert the following code :\n\n```php\n\nuse ZendFirebase\\Firebase, ZendFirebase\\Authentication\\FirebaseAuth;\n\n$auth = new FirebaseAuth();\n\n$auth-\u003esetBaseURI('https://your_url_from_firebase/');\n$auth-\u003esetServertoken('your_firebase_token');\n\n\n/* --- CREATE NEW OBJECT AND PASS CREDENTIAL --- */\n$firebase = new Firebase($auth);\n\n\n$options = []; // container options as type array\n\n$callback = 'callbackFunction'; // name of callback function as type string\n\nfunction callbackFunction(...$params){\n    // all code needed\n}\n\n$print = true;\n\n/* --- SET PATH,\n\t   NAME OF FOLDER WHERE STORE LOGS,\n\t   MILLISECONDS OF DELAY BETWEEN NEW REQUEST (not required, default 5000),\n\t   CALLBACK FUNCTION,\n\t   ARRAY OPTIONS (not required, default []),\n\t   PRINT (not required, default TRUE) --- */\n$firebase-\u003estartStream('path', 'logs/', 5000, $callback, $options, $print);\n```\n\nNow for run listener open terminal and run you file with command :\n```bash\nphp your_file_name.php\n```\n\nThis method start listener and write log file of changes.\n\n\u003chr/\u003e\n\n### PHPUnit Tests\nAll the unit tests are found in the \"/tests\" directory.\nDue to the usage of an interface, the tests must run in isolation.\n\nProject Configuration it's just setted for doing all tests with the simple command :\n\n```bash\ncd \u003cyour_project\u003e\n\nphpunit\n```\n\nIf you want to run a single test, just run :\n```bash\ncd \u003cyour_project\u003e\n\nphpunit name_and_path_of_the_file_that_you_want_to_test.php\n```\n\n#### BSD 3-Clause License\n\n[READ BSD LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuel20miglia%2Fzend_firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuel20miglia%2Fzend_firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuel20miglia%2Fzend_firebase/lists"}