1. Go to this page and download the library: Download tiriel/firestore-odm-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Symfony\Component\Uid\Uuid;
use Tiriel\FirestoreOdmBundle\Dto\Interface\PersistableDtoInterface;
class Image implements PersistableDtoInterface
{
private ?Uuid $id = null;
private ?string $path = null;
//...
public function getId(): Uuid|string
{
return $this->id;
}
// ...
use App\Dto\Image;
use Tiriel\FirestoreOdmBundle\Manager\FirestoreDtoManager;
class ImageFirestoreDtoManager extends FirestoreDtoManager
{
public const DTO_CLASS = Image::class;
}
use Tiriel\FirestoreOdmBundle\Manager\Interface\DtoManagerInterface;
class ImageController extends AbstractController
{
#[Route('/images', name: 'app_image_index', methods: ['GET'])]
public function index(DtoManagerInterface $imageManager): Response
{
// ...
interface DtoManagerInterface
{
/**
* Returns a single DTO matching the given $id
*
* @throws EntryNotFoundFirestoreException is the given id is not found
*/
public function get(string $id): ?PersistableDtoInterface;
/**
* @return iterable the DTOs matching the given criteria
* @param array $criteria
* Can be a single array matching Google SDK's `where` method,
* or an array of arrays:
*
* $criteria = ['name', '=', 'foo']
* or
* $criteria = [
* ['name', '=', 'foo'],
* ['createdAt', '>=', '01-01-1970'],
* ]
*/
public function search(array $criteria): iterable;
/**
* @return iterable the full list of documents from the collection
*/
public function getList(): iterable;
/**
* Persists a new entry in Firestore and generates a new id
* (Uuid v7 as of now)
*
* @throws NonUniqueEntryFirestoreException if the generated Uuid is not unique
*/
public function create(PersistableDtoInterface $dto): void;
/**
* @param PersistableDtoInterface $dto to be updated in the collection
* @throws EntryNotFoundFirestoreException if the DTO's id doesn't exist in the collection
*/
public function update(PersistableDtoInterface $dto): void;
/**
* @param PersistableDtoInterface $dto to be removed from the collection
* @throws EntryNotFoundFirestoreException if the DTO's id doesn't exist in the collection
*/
public function remove(PersistableDtoInterface $dto): void;
/**
* @return int the full count of documents in the collection
*/
public function count(): int;
/**
* @return string the classname of the DTO associated to this manager
*/
public function getClass(): string;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.