Download the PHP package bensontrent/firestore-php without Composer
On this page you can find all versions of the php package bensontrent/firestore-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bensontrent/firestore-php
More information about bensontrent/firestore-php
Files in bensontrent/firestore-php
Package firestore-php
Short Description Firestore PHP Client without gRPC and support for Guzzle 7. Forked from archived project ahsankhatri/firestore-php
License MIT
Homepage https://github.com/bensontrent/firestore-php
Informations about the package firestore-php
Firestore Client for PHP without gRPC
Use Google Firebase without the requirement of having the gRPC extension for php installed. This is ideal for shared hosting environments. This package is totally based on Firestore REST API
Authentication / Generate API Key
1) Visit Google Cloud Firestore API
2) Select your desired project.
3) Select Credentials
from left menu and select API Key
from Server key or Create your own credentials
Installation
You can install the package via composer:
or install it by adding it to composer.json
then run composer update
Dependencies
- PHP 7.3 and above (PHP 8+ supported)
The bindings require the following extensions in order to work properly:
If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.
Usage
Initialization
Note: You likely won't need to change the 'database' => '(default)'
line.
Adding a document
Make sure your Firebase Rules allow you to write to the $collection you wish to modify or you will get an error: You do not have permission to access the requested resource
NOTE: Pass third argument if you want your custom document id to set else auto-id will generate it for you. For example:
Or
And..
Special characters in the field name
If you want to use special characters in the field name, you have to use backticks.
You could use addNestedDocuments
if you have multiple nested objects
This just formats the array before using the addDocument
function
Inserting/Updating a document
- Update (Merge) or Insert document
Following will merge document (if exist) else insert the data.
NOTE: Passing 3rd argument as a boolean true will force check that document must exist and vice-versa in order to perform update operation.
For example: If you want to update document only if exist else MrShan0\PHPFirestore\Exceptions\Client\NotFound
(Exception) will be thrown.
format for documentPath:
- Overwirte or Insert document
Deleting a document
List documents with pagination (or custom parameters)
Note: You can pass custom parameters as supported by firestore list document
Get field from document
Firebase Authentication
Sign in with Email and Password.
Sign in Anonymously.
Retrieve Auth Token
TODO
- [x] Added delete attribute support.
- [x] Add Support for Object, Boolean, Null, String, Integer, Array, Timestamp, GeoPoint, Bytes
- [x] Add Exception Handling.
- [x] List all documents.
- [ ] List all collections.
- [x] Filters and pagination support.
- [ ] Structured Query support.
- [ ] Transaction support.
- [ ] Indexes support.
- [ ] Entire collection delete support.
Testing
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please use the issue tracker.
Credits
- Ahsaan Muhammad Yousuf
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of firestore-php with dependencies
guzzlehttp/guzzle Version ~7.0|~6.0|~5.0|~4.0
ext-curl Version *
ext-json Version *