If you have the time to read the firebase-php documentation, you can see there how to use the helper library to "connect" to firebase. But unfortunately, I think that the connection could only be established by phpunit, in other words, output can only be seen in the terminal. Since when you run the php pages in your browser, it will return fatal errors. Does anyone know how to use the helper library to connect to the firebase data without using phpunit? Thank you in advance.
Using the lib is very easy, when you just look at the source code of the tests.
There are two kinds of tests:
Now, in order to use firebase-php, you would simply do the same things as in the real functionality test. Include the lib, prepare the connection object with login credentials and then call the method you want. The interface describes, which methods you can expect in the firebaseLib class - or just look at the lib source itself.
This piece of code should get you started:
require '/path/to/libs/firebase-php/firebaseLib.php';
$url = '...';
$token = '...';
$firebase = new Firebase($url, $token);
$firebase->get('something/from/somewhere');
If you fetch the library via composer
, you might declare an autoloading classmap, too. The author hasn't done this, yet.
{
"autoload": {
"classmap": ["vendor/ktamas77/firebase-php/firebaseLib.php"]
}
}
Then simply require Composer's Autoloader with require "vendor/autoload.php";
and new Firebase
to autoload the class.
How to get the auth token
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With