Download the PHP package coffreo/ceph-odm without Composer
On this page you can find all versions of the php package coffreo/ceph-odm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download coffreo/ceph-odm
More information about coffreo/ceph-odm
Files in coffreo/ceph-odm
Package ceph-odm
Short Description Odm for Ceph using Doctrine skeleton mapper
License
Informations about the package ceph-odm
Ceph ODM
This repository presents a Ceph odm based on Doctrine mapper skeleton.
Installation
The recommanded way to install this project is using composer:
Basic usage
First, you need to instanciate an Amazon S3
client:
use_path_style_endpoint
is important, it allows to internally generate urls like http://my-ceph-server/mybucket
instead of urls like http://mybucket.my-ceph-server/
.
Once your client is instanciated, use it to create your ObjectManager
:
Note that you can pass an Doctrine\Common\EventManager
as create
second argument if you have to deal with Doctrine events.
Create a bucket
Before creating objects, you must create a bucket for storing them into:
Create a new object
Be careful, only lowercase strings are accepted as metadata keys.
Update an object
Remove an object
Duplicate an object
You can easyly clone an object by persisting it again. The only thing to keep in mind is to detach the entity:
The object will be saved with a new id. You can also save it to another bucket:
Find an object by its identifiers
Bucket and id are the primary identifiers of objects.
In repository find methods, you must use the bucket name or a bucket object in your criteria:
Is the same thing as:
Other find methods
The previous statements only return objects that the logged user owns. For now, you can only perform a search on bucket and/or id.
Filter results by metadata
You can also use metadata as filter
Be careful, it's only a filter. It's not native, all files are retrieved, filtering is done after. Furthermore the criteria metadata => []
won't return all files without metadata. It means no metadata filter, so all the files will be returned according by the possible other criteria.
Sort results
The results can be sorted but it's not a database sort. The sort is done programmatically so it's not optimized and it's applyed after the bucket limit. By default, the results are ordered by bucket name and id. For ordering a query by a filename metadata (desc) and by id (asc):
Truncated results
For the find methods which return many files (findBy
and findAll
), if there is too many results (more than the limit you specified or 1000 by default), the names of the buckets where all the files couldn't be returned are returned by getBucketsTruncated
:
Resume truncated queries
You can use the continue
parameter to resume a previously truncated query. For instance for retrieving the files of mybucket
that was not retrieved by the query above:
For making this possible, the repository keeps a pointer on the last file returned by bucket. Note that this pointer is modified when another query is done on the bucket; the calls bellow update the pointer for bucket mybucket
:
findBy(['bucket' => 'mybucket'])
findOneBy(['id' => 'myid'])
findBy([])
findAll
Onlyfind
never modify the internal pointer.
This is another example for retrieving all files of the connected user:
Note that you can use findAll
on the first call too.
Finally, the findByFrom
method returns files starting after the given identifier:
Lazy load
When queries that return multiple results are used (i.e. queries which don't specify bucket and id), bin
and metadata
are not loaded directly since getting them requires to perform another specific server call per result. This library uses in these cases a lazy load strategy and retrieves bin and metadata only when getBin
, getAllMetadata
, getMetadata
or setMetadata
is called. You won't normally have to worry about it but it could be useful to be aware about it.
All versions of ceph-odm with dependencies
doctrine/skeleton-mapper Version 0.0.1
aws/aws-sdk-php Version ^3.85
ramsey/uuid Version ^3.8