1. Go to this page and download the library: Download devbry/firebase-php 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/ */
// -- Firebase API commands
$firebase->set($path, $value); // stores data in Firebase
$value = $firebase->get($path); // reads a value from Firebase
$firebase->delete($path); // deletes value from Firebase
$firebase->update($path, $data); // updates data in Firebase
$firebase->push($path, $data); // push data to Firebase
// -- Firebase PHP Library commands
$firebase->setToken($token); // set up Firebase token
$firebase->setBaseURI($uri); // set up Firebase base URI (root node)
$firebase->setTimeOut($seconds); // set up maximum timeout / request
public function setFirebaseValue($path, $value) {
$firebase = new Firebase('https://radiant-fire-2427.firebaseio.com', 'czvEX8vMU8FZn4wYCvf466P3J6zH5ZlKQeuwxmEZ');
$firebase->set($path, $value);
}
public function setFirebaseValue($path, $value, $firebase) {
$firebase->set($path, $value);
}
re_once '<path>/lib/firebaseStub.php';
class MyClass extends PHPUnit_Framework_TestCase
{
public function testSetFirebaseValue() {
$myClass = new MyClass();
$firebaseStub = new FirebaseStub($uri, $token);
$myClass->setFirebaseValue($path, $value, $firebaseStub);
}
}
bash
cd <your_project>
composer
bash
$ phpunit tests/firebaseTest.php
bash
$ phpunit tests/firebaseStubTest.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.