Reputation: 101
I am using ktamas77/firebase-php at github to connect my Firebase data.
My code below. Replaced of confidential info with ******.
<html>
<head>
<title>My web</title>
</head>
<body>
<?php
require_once 'firebase/firebaseLib.php';
require_once 'firebase/firebaseStub.php';
require_once 'firebase/firebaseInterface.php';
echo "1";
const DEFAULT_URL = 'https://********.firebaseio.com/';
const DEFAULT_TOKEN = '***************************************';
const DEFAULT_PATH = '/firebase/example';
echo "2";
$firebase = new Firebase(DEFAULT_URL, DEFAULT_TOKEN);
echo "3";
?>
</body>
</html>
I also tried:
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
Output is: 1 2
. It seems it fails while it is trying to create the new Firebase.
What am I doing wrong? Thanks!
Upvotes: 9
Views: 400
Reputation: 21
For people who are still searching for an solution without using composer you could try the following:
<?php
require_once('./src/firebaseLib.php');
require_once('./src/firebaseStub.php');
require_once('./src/firebaseInterface.php');
$URL = 'xxx';
$TOKEN = 'xxx';
$firebase = new FirebaseLib($URL, $TOKEN);
// Reading the stored string
$name = $firebase->get('/',['orderBy' => '"ID"','equalTo' => '"1309"']);
var_dump($name);
?>
Upvotes: 0
Reputation: 41
Try it. but i am not sure because evrything look fine from here:
const DEFAULT_URL = 'h://abc.com/';
const DEFAULT_TOKEN = 'yourToken:XYZ';
const DEFAULT_PATH = '/firebase/example';
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
Upvotes: 1
Reputation: 1378
first of all, enable your PHP error logging error_log(E_ALL)
to get the error message retrieved
also, check your internet connection because everything looks fine
Upvotes: 0
Reputation: 36
Are you sure your library is loaded properly? Pls add directory/file structure.
You can test loaded library with
class_exists ('Firebase')
or
file_exists ( 'firebase/firebaseLib.php' );
Upvotes: 1