A simple and clean CRUD PHP library for Google Firebase datastore. This library, allows you to create, read, update and delete records stored on your Google Firebase database.
To intall the library, kindly execute the command composer require coderatio/phpfirebase:v1.0
Or composer require coderatio/phpfirebase
.
To start using, make sure you create a folder and save your Google Firebase service account key json file.
To create new record, do this...
require 'vendor/autoload';
use Coderatio\PhpFirebase\PhpFirebase;
$pfb = new PhpFirebase($pathToSecretKeyJsonFile);
$pfb->setTable('posts');
$pfb->insertRecord([
'title' => 'Post one',
'body' => 'Post one contents'
], $returnData);
//The $returnData which is boolean returns inserted data if set to true. Default is false.
To read created records, do this...
// Getting all records
$pfb->getRecords();
// Getting a record. Note: This can only be done via the record id.
$pfb->getRecord(1);
To update a record, do this...
// This takes the record ID and any column you want to update.
$pfb->updateRecord(1, [
'title' => 'Post one edited'
]);
To delete created record, do this...
// This takes only the record ID. Deleting all records will be added in Beta-2
$pfb->deleteRecord(1);
Kindly send fork the repo and send a pull request or find me on Twitter