Download the PHP package tatter/firebase without Composer

On this page you can find all versions of the php package tatter/firebase. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package firebase

Tatter\Firebase

Firebase integration for CodeIgniter 4

Coverage Status

Quick Start

  1. Install with Composer: > composer require tatter/firebase
  2. Edit .env and add the path to your Firebase credentials: GOOGLE_APPLICATION_CREDENTIALS = ../credentials/keyfile.json
  3. Access components via the service: $authentication = service('firebase')->auth;
  4. Use the Firestore Collection and Entity to model your data: $widget = collection(WidgetCollection::class)->get($widgetId);

Description

This is a CodeIgniter 4 integration of Kreait\Firebase, the "Unofficial Firebase Admin SDK for PHP":

It provides a convenience service and custom Firestore classes to use your Firebase project within CodeIgniter 4. Please pay attention to the requirements of the underlying services:

Notably, you must have the gRPC PHP extension and the credentials file to a Service Account with the Project -> Editor or Project -> Owner role.

Installation

Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date:

Or, install manually by downloading the source files and adding the directory to app/Config/Autoload.php.

Note: As of February 5, 2022 this library fully supports PHP 8.1, however Google's Protobuf has an incompatibility (hopefully fixed soon: https://github.com/protocolbuffers/protobuf/issues/9293).

Credentials

You must provide a key file with your application's service account credentials. The standard way to do this is to add keyfile.json to your project and edit .env to its path (relative to public/):

GOOGLE_APPLICATION_CREDENTIALS = ../keyfile.json

WARNING Make sure you exclude the key file from any repository updates!

To generate a key file from your Firebase project:

  1. Firebase Project Home
  2. Project Settings (gear)
  3. Service Accounts
  4. Firebase Admin SDK
  5. Generate new private key

For more info on acquiring credentials see the Firestore Quick Start Guide

For more information on credential specification see the SDK setup docs

Usage

Load the Firebase service:

The service will handle creating and caching each component as you need them. Access components by their name:

You can also use the service to access all the functions of Kreait\Firebase\Factory directly, for example if you wanted a separate component instance:

See the SDK docs for a list of supported components. Available at the time of this writing:

Caller

While not yet officially supported by the Firebase SDK, this library includes a component for Firebase callable functions. A simple example shows all its features:

Firestore

This library provides access to the Firestore database directly via FirestoreClient. Use the helper function for direct access to a shared instance of the client:

Since the SDK and Google classes already represent a full database implementation there is no need for a framework database layer. You can interact directly with the Firestore classes according to Google's User Guide.

Collection

The Collection class is inspired by the framework's Model and handles most of the pre- and post-processing that developers are used to. All you need to supply is the name of the collection and the Entity type to use:

Instantiating

You can create your collection instances just like you would a Model. The Firestore Helper also contains a helper function to create and manage shared instances, just like the framework's model() helper:

By default a new Collection will create a CollectionReference to the top-level collection matching it's NAME constant. Alternatively you may pass in a CollectionReference directly for it to use. Use the second parameter to the collection() function to make instant subcollections of any Firestore\Entity or DocumentReference:

Methods

Collection supplies the following CRUD methods:

And support methods:

Additionally, these methods access metadata about the underlying Firestore (sub)collection:

And finally some familiar Model-inspired validation methods:

Retrieving Documents

You may use the Firestore client directly to return snapshots and convert them to your Entity of choice with fromSnapshot(), but Collection also allows specifying an overriding state for list(). This can be an explicit CollectionReference or (more helpful) an instance of Google\Cloud\Firestore\Query, which opens up the possibility of using filters, sorts, and limits as well as traversing collection groups:

To make this even easier, Collection will "pass through" the following method calls to the underlying collection:

This allows for even easier method chaining:

Note that list() always returns a Traversable so documents are only retrieved and converted ot Entities as they are actually needed

Entity

This library also comes with its own Firestore Entity that handles Google's timestamp conversions and these methods to access metadata about the underlying Firestore document:


All versions of firebase with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
google/cloud-firestore Version ^1.10
google/protobuf Version ^3.3
grpc/grpc Version ^1.1
kreait/firebase-php Version ^5.0 || ^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tatter/firebase contains the following files

Loading the files please wait ....