Download the PHP package tiriel/firestore-odm-bundle without Composer
On this page you can find all versions of the php package tiriel/firestore-odm-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tiriel/firestore-odm-bundle
More information about tiriel/firestore-odm-bundle
Files in tiriel/firestore-odm-bundle
Package firestore-odm-bundle
Short Description Small and Basic ODM for Google Cloud Firestore Database
License MIT
Informations about the package firestore-odm-bundle
Firestore ODM Bundle
A small bundle to persist and manage entities with Google Cloud Firestore Database in Symfony applications.
Requirements
This bundle requires PHP 8.2+ and Symfony 7+.
This bundle also relies heavily on Google Glouc Firestore PHP Client, and its technical requirements are the same (most notably PHP gRPC and Protobuf extensions). See Google's documentation for more details.
Installation
If you have Symfony Flex, a contrib recipe is available:
That's it, you're good to go.
If you haven't got Flex installed, first require the bundle as shown above.
Then, enable the bundle in the config/bundles.php
file:
You can now create a config/packages/tiriel.yaml
with the following content:
Usage
DTOs or Entities
Every DTO class in your application will create a new collection based on its FQCN in your Firestore database.
You can use whatever DTO you want as entities. The only requirement is that they implement
Tiriel\FirestoreOdmBundle\Dto\Interface\PersistableDtoInterface
as a marker, and to ensure a getId()
method
is present. This id
can be a string, integer, or Symfony Uuid
.
Example:
You can now create a manager for your DTO.
DTO Managers
To perform queries on your Firestore DTOs, you need to create a manager extending Tiriel\FirestoreOdmBundle\Manager\FirestoreDtoManager
.
Inside, override the value of the FirestoreDtoManager::DTO_CLASS
constant by specifying which DTO this manager is attached to:
And you're done, you can use your new DTO and its manager.
Internally, the bundle creates an alias for your Manager to be autowired as DtoManagerInterface $dtoNameManager
.
Example with our ImageFirestoreDtoManager
:
Available methods
All managers provide you with the same interface and methods:
All managers also include a protected CollectionReference $collection
object from Google\Cloud\Firestore\CollectionReference
.
You can use it to create your own custom queries or pagination inside your Manager.
Usage with Symfony Security
If you want to use Firestore to store the users for your security flow, you can check my other bundle: Firestore-Security-Bridge.
This package defines classes and User Providers to help you use Firestore as the source of your users.
All versions of firestore-odm-bundle with dependencies
symfony/config Version ^6.4||^7.0
symfony/dependency-injection Version ^6.4||^7.0
symfony/serializer Version ^6.4||^7.0
google/cloud-firestore Version ^1.43
symfony/uid Version ^6.4||^7.0
symfony/property-access Version ^6.4||^7.0