PHP code example of coderatio / phpfirebase

1. Go to this page and download the library: Download coderatio/phpfirebase 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/ */

    

coderatio / phpfirebase example snippets



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.

// Getting all records
$pfb->getRecords();

// Getting a record. Note: This can only be done via the record id.
$pfb->getRecord(1); 

// This takes the record ID and any column you want to update.
$pfb->updateRecord(1, [
  'title' => 'Post one edited'
]);


 // This takes only the record ID. Deleting all records will be added in Beta-2
 
 $pfb->deleteRecord(1);