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!
Q: Can I use Firebase with PHP? A: Yes, Firebase provides a comprehensive API for integrating the platform with your PHP projects.
The Firebase Admin Java SDK enables access to Firebase services from privileged environments (such as servers or cloud) in Java. Currently this SDK provides Firebase custom authentication support, and Firebase realtime database access. For more information, visit the Firebase Admin SDK setup guide.
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' );
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