Giter VIP home page Giter VIP logo

firebase-php's Introduction

Firebase php

Php implementation of Firebase API.

Why

This package is built to be simple, scalable and configurable to allow easy integration in other packages or frameworks (ex: laravel-firebase ).

This package uses google/auth to generate OAuth2.0 tokens from the service account and guzzlehttp/guzzle as http library.

Install

Install it with composer via

composer require plokko/firebase-php

Usage

All the calls on the API are made using a Firebase OAuth2.0 token, this token is generated using your ServiceAccount informations.

Service Account

To use the API you need to authenticate the requests with your service account: this is done by the ServiceAccount class that uses your Firebase ServiceAccount json credential file. You can download your service account json file from the Firebase console in settings > service accounts, keep in mind to store this file in a secure non-public location.

use Plokko\Firebase\ServiceAccount;

//Use one of those methods:
$sa = new ServiceAccount('/path/to/your/serviceaccount/file.json');
$sa = new ServiceAccount('{"type":"service_account",..............}');
$sa = new ServiceAccount(['type'=>'service_account',/*...*/]);

Accepted methods for the constructor are:

  • string: ServiceAccount file content (json string)
  • string: path to the serviceAccount json file
  • array: php-translated array of the service account content

You can also add a token cache handler via the setCacheHandler method that accepts an implementation of CacheItemPoolInterface to allow custom cache integrations.

see google/auth MemoryCacheItemPool for an example implementation:

$handler = new Google\Auth\Cache\MemoryCacheItemPool\MemoryCacheItemPool();
$sa->setCacheHandler($handler);

FCM

This package implements FCM Http v1 Api

see FCM docs

Real time database

This package includes the Firebase Real time database API integration

see Real time database docs

firebase-php's People

Contributors

andrewalf avatar pety-dc avatar plokko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

firebase-php's Issues

Multiline or HTML Body

Is it possible to include multiple lines or HTML in the content body.

$message->notification
->setTitle('Notification title')
->setBody('firstLine\nSecond Line');

OR

$message->notification
->setTitle('Notification title')
->setBody('firstLine
second Line');

Any insight to the possibilities and limitation would be appreciated. thanks

Composer require error

composer require plokko\firebase-php gives error:

[InvalidArgumentException]                                                                                                                                                                                      
Could not find a matching version of package plokkofirebase-php. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (dev).

Old Version on Composer

Would be cool if you could update the version on Composer too, the property "mutable content" is still missing there

Request->submit

Should the following code for the submit method

return ($json && isset($json['message']['name']))?$json['message']['name']:null;

not be

return ($json && isset($json['name']))?$json['name']:null;

As the message object doesn't exist it's just returning null.

ApnsConfig

https://github.com/plokko/firebase-php/blob/master/src/FCM/Message/ApnsConfig.php#L28
This will throw an exception (InvalidArgumentException)

The JSON dictionary object must contain an aps key, the value of which is a dictionary containing data used by the system to deliver the notification.

For example
https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1

Can not submit data as nested array

Hello,

Thank you for your awesome code, but I have a problem sending this kind of nested array in the data property

$message->data->fill(
      [
	 “type_of_food” => ”vegetable”,
	 “example” => 
                [
                    0 => 
                      [
                          "red" => “carrots”,
                          "green" => “broccoli”
                      ]
	       ]
      ]
)

Could you please help..the "example" part still recognized as an array in Flutter code

Condition in Message

Hello, how can I create a message that reaches all users in app?, inside FCM console you can use a "condition", wich I see is present in this library, but is seems not no be aplied in "Plokko\Firebase\FCM\Message.php" as a possible Target.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.