Giter Site home page Giter Site logo

firebase-bundle's Introduction

#Firebase Symfony2 Bundle

SensioLabsInsight Packagist Packagist Code Coverage Scrutinizer Code Quality Build Status

A Symfony2 Bundle for the Firebase PHP client.

Installation

Download the bundle

Execute the following from the project root directory

  composer require kreait/firebase-bundle

Enable the bundle

Then, enable the bundle by adding the following line in the `app/AppKernel.php file of your project:

// app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Kreait\FirebaseBundle\KreaitFirebaseBundle(),
        );

        // ...
    }
}

Add minimal configuration

Add the following to app/config/config.yml

kreait_firebase:
  connections:
    main:
      host: prefix-suffix-1234.firebaseio.com

Setup complete!

Configuration

Following configuration

kreait_firebase:
  connections:
    main:
      scheme: https
      host: prefix-suffix-1234.firebaseio.com
      secret: <your firebase secret>
      references:
        users: data/users
        images: data/images

will automagically register the following services

  • kreait_firebase.connection.main (instance of Kreait\Firebase\Firebase)
  • kreait_firebase.reference.users (instance of Kreait\Firebase\Reference)
  • kreait_firebase.reference.images (instance of Kreait\Firebase\Reference)

Usage

Please see https://github.com/kreait/firebase-php#documentation for the full documentation

Retrieving a Firebase connection

$firebase = $this->container->get('kreait_firebase.connection.main');

Retrieving a Firebase Reference

$users = $this->container->get('kreait_firebase.reference.users');

Authentication

To use authentication, you have to include the firebase token generator into your project

composer require firebase/token-generator

You also need to set the Firebase secret in your configuration.

Then, in your code, you can authenticate a request like this:

$firebase       = $this->container->get('kreait_firebase.connection.main');
$tokenGenerator = $firebase->getConfiguration()->getAuthTokenGenerator();

$adminToken     = $tokenGenerator->createAdminToken();

$firebase->setAuthToken($adminToken);

This procedure is quite cumbersome at the moment, but will be made more conveniant in an upcoming release.

firebase-bundle's People

Contributors

iamtankist avatar jeromegamez avatar

Watchers

 avatar  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.