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 plokko avatar pety-dc avatar

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.