https://github.com/coderatio/phpfirebase
A simple and clean CRUD PHP library for Google Firebase datastore
https://github.com/coderatio/phpfirebase
Last synced: about 1 year ago
JSON representation
A simple and clean CRUD PHP library for Google Firebase datastore
- Host: GitHub
- URL: https://github.com/coderatio/phpfirebase
- Owner: coderatio
- License: mit
- Created: 2018-11-19T00:12:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-02T14:22:13.000Z (over 7 years ago)
- Last Synced: 2024-10-12T06:21:17.404Z (over 1 year ago)
- Language: PHP
- Size: 20.5 KB
- Stars: 29
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Firebase
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.
## Installation
To intall the library, kindly execute the command `composer require coderatio/phpfirebase:v1.0` Or `composer require coderatio/phpfirebase`.
## How to use
To start using, make sure you create a folder and save your Google Firebase service account key json file.
## Creating new records (C)
To create new record, do this...
```php
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.
```
## Reading records (R)
To read created records, do this...
```php
// Getting all records
$pfb->getRecords();
// Getting a record. Note: This can only be done via the record id.
$pfb->getRecord(1);
```
## Updating records (U)
To update a record, do this...
```php
// This takes the record ID and any column you want to update.
$pfb->updateRecord(1, [
'title' => 'Post one edited'
]);
```
## Deleting records (D)
To delete created record, do this...
```php
// This takes only the record ID. Deleting all records will be added in Beta-2
$pfb->deleteRecord(1);
```
## Contribution
Kindly send fork the repo and send a pull request or find me on Twitter