ktamas77 / firebase-php Goto Github PK
View Code? Open in Web Editor NEWFirebase PHP Client
Firebase PHP Client
I m getting this error:
Fatal error: Cannot use Kreait\Firebase\Http\Auth as Auth because the name is already in use vendor\kreait\firebase-php\src\Firebase\Database.php on line 10
But it doesn't make sense. The conflict comes from the Auth.php because there is already a Class with name Auth but the namespace is different for both, so it should not matter. Right?
Disabling line 10 on Database.php
removes the error. Which is am using as a fix.
Why when push data, class return txt?
Trying to do $database->ref('some/path')->orderByChild('childname').equalTo('stringvalue')->...
Will throw an error: "Constraint index field must be a JSON primitive".
So it seems strings don't work, but performing the same query in, say, javascript Firebase, is allowed with strings.
Hi, guys.
I have a dictionary inside the Firebase.
Sometimes I want the information and, it returned a NULL data, even in cases where the information exists in database.
To solve this problem I used an ugly solution: a loop with 3 repetitions searching the information, and a condition when while the variable still empty, then do the loop.
My main question is: there is a better way to do this?
The "$firebase->setTimeOut($seconds);" with the more time will resolve?
Hello, I am getting an error while scanning the field through the foreach when there is no element of the table I wanted to just display there is no element registered, however I can not check the null test on the return of get someone could help me?
$ListFire = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
$getListFire = $ListFire->get('/users/');
$decodeListFire = json_decode($getListFire);
if($decodeListFire===null){
// foreach....
}
// Not Work not return true or false in If
I'm probably an idiot for asking this, but when running the example I get this:
Fatal error: Class 'Firebase' not found in (.....)/firebase-php/index.php on line 8
The code I'm using is this:
<?php
require 'autoload.php';
const DEFAULT_URL = 'https://xxxx.firebaseio.com';
const DEFAULT_TOKEN = 'yyyy';
const DEFAULT_PATH = '';
$firebase = new Firebase(DEFAULT_URL, DEFAULT_TOKEN);
$test = array(
"foo" => "bar",
"i_love" => "lamp",
"id" => 42
);
$dateTime = new DateTime();
$firebase->set(DEFAULT_PATH . '/' . $dateTime->format('c'), $test);
?>
How do I properly use print=silent?
I wan't to make sure connections are immediately closed.
Or, how to make sure a connection is closed?
when i want to test just example code i get this issue.
recv() failed (104: Connection reset by
peer
database secrets are deprecated now..
would it be possible to implement authentication via the new Service Account json file?
this library uses it, but is heavily reliant on guzzle which has issues under Google Cloud SDK shell
https://github.com/kreait/firebase-php
thanks
j
Hi guys. I tried really everything, but it still slow. I even implemented "use one curl for all quests" but it still slow. I have ten quests and I wait for page 7sec. which is too much. Please help, I need to finish project.
Currently I have implemented your library with user.token, but won't the token expire soon? How can I make sure that I always have a valid token?
Hello, the script works very slow to 7 seconds to perform each operation, I know that the response of the firebase is fast so I wonder how it does to improve the response speed performance of the script.
It would be nice if you could call .auth(TOKEN) and then the library would automatically append ?auth=TOKEN to requests.
Is this currently supported on the library https://www.firebase.com/docs/android/guide/login/password.html ?
Hi! Is it possible to use this lib with the new firestore db?
Please explain the parameters to pass into the push function?
Thanks.
push($path, $data, $options);
Hi there!
Can you suggest me i want to update
$this->firebase = new \Firebase\FirebaseLib($DEFAULT_URL, $DEFAULT_TOKEN);
$uzrs = json_decode($this->firebase->get('users'));
foreach($uzrs as $user){
echo "<pre>";
foreach($user->chat as $msgs){
if($msgs->type=="image"){
// HOW TO UPDATE HEREEEEEEEEEEEEEEEEEE
//HOW TO ADD SOME ADDITIONAL INFO AT CURRENT PATH?
$this->firebase->push($user->chat,['name'=>'TEST','type'=>'text','message'=>'test test']); /// <!---- THIS NOT WORKING
}
}
With the following code...
<?php
require __DIR__.'/vendor/autoload.php';
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
const DEFAULT_URL = 'https://dbname.firebaseio.com/';
const DEFAULT_TOKEN = '<tokenfromfirebasewebpage>';
const DEFAULT_PATH = '/firebase/example';
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
// --- storing an array ---
$test = array(
"foo" => "bar",
"i_love" => "lamp",
"id" => 42
);
$dateTime = new DateTime();
$firebase->set(DEFAULT_PATH . '/' . $dateTime->format('c'), $test);
// --- storing a string ---
$firebase->set(DEFAULT_PATH . '/name/contact001', "John Doe");
// --- reading the stored string ---
$name = $firebase->get(DEFAULT_PATH . '/name/contact001');
I am getting the following error:
In the composer.json I have:
"require": {
"php": ">=5.2.4",
"kreait/firebase-php": "^3.0"
}
I am using CodeIgniter 3 but I think that isn't the problem, any idea what it could be?
Hey,
When i run the firebaseTest.php on my remote server (Free Web Hosting BIZ.NF) it doesn't work. I debugged the script, and it does stablish a connection with firebase succesfully but the push/read/update methods don't work.
Whilst on my local server, the script works like a charm.
Could it be something wrong with my remote server?
Hello, I would like to know if there is a plan to include uploading images through firebase storage, I had to implement the upload in javascript because of the lack of this resource in the lib but I would like to do it via php is it possible?
Can we get array using order by?
Hi,
I tried using your library and added it to my zf2 application using composer.
I added this line to my composer.json file
"ktamas77/firebase-php": "dev-master"
The library was successfully added to my zf2 application, but I can't call the Firebase class in the code.
I tried the following
$fb = new Firebase($url, $token);
$fb = new \Firebase($url, $token);
Sorry for the newbie question, but how do I fix this?
firebase-php
promptly closes the curl handle after each request, making it impossible to take advantage of the underlying protocol's Keep-Alive capability. Since all Firebase API requests use SSL, using Keep-Alive would save a massive amount of time and resources (SSL handshake in addition to TCP handshake) when multiple requests are made in quick succession.
Enabling Keep-Alive with PHP curl is as simple as reusing the same curl handle without closing it.
Hello Katmass77 Team,
I am currently implementing the get,push,update and set operations for my web application, and
encountered the following problems:
where $allCategories is:
array (
'name' => 'brand_categories',
'value' => 'cid1,cid2'
)
Can you suggest us if we are implementing in a wrong way or is there a problem with the framework.
What is the license for firebase-php?
Thanks
can i make custom token through this library, if yes how ?
Thank you!
I use firebase-php of ktamas77. I try to get data with orderBy => 'data_id' (child) and equal to 'Test' but it report
"error" : "orderBy must be a valid JSON encoded path"
$test = $initFirebase->get('/notification',array('orderBy' => 'data_id', 'equalTo' => 220));
Authentication by JWT would be desirable:
https://www.firebase.com/docs/rest/guide/user-auth.html#section-authenticating-servers
We are creating a client for Haskell, where we just are on the same thing:
https://github.com/sphaso/firebase-haskell-client
I would be happy to be assigned to that.
limit options in GET-method seem not working. I tried:
$firebase->get('database/posts', ['limit' => 10]);
Everything is not different.
Hello guys.
How do I get DEFAULT_TOKEN configuration ?
I was using Firebase token generator php but it not working.
Can you help me ?
Thank a lot
I have an application in which I installed this library and it was working fine. But when I push my application using git push firebase_php folder gets changed to something. When I go to my bitbucket dasboard it is showing firebase-php โ fbfeefe [fbfeefe]. I earlier had firebase jwt library so I thought git is getting confused with these two libraries. So I removed firebase jwt library but still it is showing same error.
(Translated by Google)
I think it would be useful, to be able to establish an Array of references, to the method DELETE, to be able to eliminate many places, with a single call
$info = '/path/to/delete'
$firebase->delete( $info )
or
$info[] = '/path/to/delete/1'
$info[] = '/path/to/delete/2'
$firebase->delete( $info )
Hi everyone, I'm searching for a way to simulate a transaction with Rest API. I seen that with this module there's no way to do it. What's the best way to simulate it? Thanks in advance! P.S. I'm sorry for my bad english.
Hi @ktamas77 I am using your Library to get data from firebase using PHP it's good
but here is the problem when I am connected with firebase using library getting 3-4 second document response time in browser network.
Can you please help me to decrease this page response time?
Thanks
-Mitul Bhadeshiya
Hi,
Actually i need to apply rules to my app database. And after applying data display as it is with use of the library. For that I use JWT also to generate custom token and get data with that token also. But not working. JWT I get grom here : https://github.com/luciferous/jwt.
Token generation and signInWithCustomToken process through javascript run successfully. But after that applying same token to get data with php not working. and display:
{error: "Unauthorized request."}
So let me know where i was wrong. for the demo purpose I attach code.
How to check existing data in specific location ?
CURLOPT_SSL_VERIFYPEER
should never be set to false
in any production environment; I'd suggest just flipping the false
to true
here:
https://github.com/ktamas77/firebase-php/blob/master/src/firebaseLib.php#L227
It would be great if there was a simple way to check if a token is valid for entering data at a specific path. Is there a workaround to achieve this?
The Firebase API offers orderBy and advanced query options. The _getJsonPath function currently appends ".json" to the end of the path without regard to the $path. This should be corrected so that query strings can be passed in the $path.
I may fork and solve, but at least wanted the issue reported in case I don't get back here.
Hi
This might seem a stupid question but I am really stumped.
I have the code on my local server and it works fantastically. The local writes out to firebase, my app picks it up nicely etc. Works as expected.
However, when I upload it to my remote server, which is an exact mirror, it all seems to break. In my error logs it says
PHP Fatal error: Class 'Firebase\FirebaseLib' not found in.....
Is there a way to install this manually, rather than composer? I am very unfamiliar with composer.
Best regards
Firebase created a new authentication putting only the secret key returns "Cannot parse token". Now this module only works in public firebase database. Kindly help to resolve this issue.
I tried to use the library as README.md, PHP can never load class "Firebase".
It turns out that there is no "Firebase" class. I don't know how the other guys could even load it.
This one worked.
$firebase = new \Firebase\FirebaseLib($DEFAULT_URL, $DEFAULT_TOKEN);
This one does not work
$firebase = new Firebase(DEFAULT_URL, DEFAULT_TOKEN);
We are testing $firebase->set() for a large amount of data.
The scenario could be replicated in php with this snippet:
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
foreach($bigamountofdata as $data){
$firebase->set($my_url, $data);
}
When the amount of data is very big and cycle iterate after some seconds the $firebase->set() will fail. It will return a 502 Bad Gateway response in the firt place and then CURL will stop working with this error:
Call to URLFetch failed with application error 1 (URL using bad/illegal format or missing URL) for url MY_URL
.
To fix this we edited our code this way:
foreach($bigamountofdata as $data){
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
$firebase->set($my_url, $data);
}
Is this the expected behaviour?
I can easily read or write data, but what about user authentication data?
is the platform is working on ubuntu 12:04?
because i try using ubuntu server 12.04 its not working, even though i try on my mac is work well
thanks
Hi,
I've used the "get" method to retrieve query data, but it seem didn't work, the error is:
{ "error" : "Constraint index field must be a JSON primitive" }
Pls note that if I put the URL on address bar, I still can get the matched data
https://goldenmuse.firebaseio.com/user.json?orderBy="email"&startAt="[email protected]"&endAt="[email protected]"
Could anyone help me resolve this?
Thanks.
Related issue: #19
Related PR: https://github.com/ktamas77/firebase-php/pull/25/files
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.