PHPackages                             coffreo/ceph-odm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. coffreo/ceph-odm

ActiveLibrary[Database &amp; ORM](/categories/database)

coffreo/ceph-odm
================

Odm for Ceph using Doctrine skeleton mapper

0.4.0(7y ago)13[2 issues](https://github.com/Coffreo/ceph-odm/issues)[1 PRs](https://github.com/Coffreo/ceph-odm/pulls)PHPPHP ^7.1

Since Jan 23Pushed 7y ago3 watchersCompare

[ Source](https://github.com/Coffreo/ceph-odm)[ Packagist](https://packagist.org/packages/coffreo/ceph-odm)[ RSS](/packages/coffreo-ceph-odm/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (5)Versions (7)Used By (0)

Ceph ODM
========

[](#ceph-odm)

[![Build Status](https://camo.githubusercontent.com/04fee6e814ac9568fe34deeb938a6b06398c2da50912056efa953ba2cb5832bf/68747470733a2f2f7472617669732d63692e6f72672f436f666672656f2f636570682d6f646d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Coffreo/ceph-odm)[![codecov](https://camo.githubusercontent.com/bbda32d20e86e998a8799dca2343e5162da3a1eefa0d28913b0a3fd68ead6f03/68747470733a2f2f636f6465636f762e696f2f67682f436f666672656f2f636570682d6f646d2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Coffreo/ceph-odm)

This repository presents a Ceph odm based on Doctrine mapper skeleton.

Installation
------------

[](#installation)

The recommanded way to install this project is using composer:

```
$ composer require coffreo/ceph-odm
```

Basic usage
-----------

[](#basic-usage)

First, you need to instanciate an `Amazon S3` client:

```
$s3Client = new \Aws\S3\S3Client([
    'region' => '',
    'version' => '2006-03-01',
    'endpoint' => 'http://my-ceph-server/',
    'use_path_style_endpoint' => true,
    'credentials' => ['key' => 'userAccessKey', 'secret' => 'userSecretKey']
]);
```

`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`:

```
$objectManager =  \Coffreo\CephOdm\Factory\ObjectManagerFactory::create($s3Client);
```

Note that you can pass an `Doctrine\Common\EventManager` as `create` second argument if you have to deal with Doctrine events.

### Create a bucket

[](#create-a-bucket)

Before creating objects, you must create a bucket for storing them into:

```
$objectManager->persist(new \Coffreo\CephOdm\Entity\Bucket('my-bucket'));
$objectManager->flush();
```

### Create a new object

[](#create-a-new-object)

```
$object = new \Coffreo\CephOdm\Entity\File();
$object->setBucket(new \Coffreo\CephOdm\Entity\Bucket('my-bucket'));
$object->setFilename('test.txt');
$object->setBin('my-file-content');
$object->setAllMetadata(['my-metadata1' => 'my-value1', 'my-metadata2' => 'my-value2']);
$objectManager->persist($object);
$objectManager->flush();
$objectManager->clear();

echo $object->getId(); // e223fc11-8046-4a84-98e2-0de912d071e9 for instance since object is stored
```

*Be careful, only lowercase strings are accepted as metadata keys.*

### Update an object

[](#update-an-object)

```
$object->setBin('my-content-updated);
$object->addMetadata('my-metadata2', 'my-new-metadata-value);
$objectManager->flush();
$objectManager->clear();
```

### Remove an object

[](#remove-an-object)

```
$objectManager->remove($object);
$objectManager->flush();
$objectManager->clear();
```

### Duplicate 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:

```
$object = $fileRepository->find(/* ... */);
$objectManager->detach($object);

// You can update (or not) the object properties before saving it
$object->setBin('my-other-content');

$objectManager->persist();
$objectManager->flush();
```

The object will be saved with a new id. You can also save it to another bucket:

```
$object = $fileRepository->find(/* ... */);
$objectManager->detach($object);

$object->setBucket(new \Coffreo\CephOdm\Entity\Bucket('my-bucket-2));
// You can update (or not) the object properties before saving it
$object->setBin('my-other-content');

$objectManager->persist();
$objectManager->flush();
```

### Find an object by its identifiers

[](#find-an-object-by-its-identifiers)

Bucket and id are the primary identifiers of objects.

```
$fileRepository = $objectManager->getRepository(\Coffreo\CephOdm\Entity\File::class);
$object = $fileRepository->find([new \Coffreo\CephOdm\Entity\Bucket('my-bucket'), 'e223fc11-8046-4a84-98e2-0de912d071e9']);

echo $object->getFilename();    // test.txt
```

In repository find methods, you must use the bucket name or a bucket object in your criteria:

```
$object = $fileRepository->find([new \Coffreo\CephOdm\Entity\Bucket('my-bucket'), 'e223fc11-8046-4a84-98e2-0de912d071e9']);
```

Is the same thing as:

```
$object = $fileRepository->find(['my-bucket', 'e223fc11-8046-4a84-98e2-0de912d071e9']);
```

### Other find methods

[](#other-find-methods)

```
$objects = $fileRepository->findAll();  // All objects of all buckets

$objects = $fileRepository->findBy(['bucket' => 'my-bucket']);  // All objects of the bucket
$objects = $fileRepository->findBy(['id' => 'e223fc11-8046-4a84-98e2-0de912d071e9']); // All objects in any bucket of the given id
```

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

[](#filter-results-by-metadata)

You can also use metadata as filter

```
$objects = $fileRepository->findBy(['bucket' => 'my-bucket', 'metadata' => ['mymetadata' => 'myvalue']]);
```

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

[](#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):

```
$objects = $fileRepository->findBy([], ['metadata' => ['filename' => -1], 'id' => 1]);
```

### Truncated results

[](#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`:

```
// Let's set the limit to 10
$objects = $fileRepository->findBy(['bucket' => 'mybucket'], [], 10);
foreach ($objects->getBucketsTruncated() as $bucketName) {
    // some files of the bucket $bucketName ('mybucket' in our case) was not returned
}
```

### Resume truncated queries

[](#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:

```
// It may be necessary to do this call many times. Do this call in a loop until $objects->getBucketsTruncated() returns an empty array.
$objects = $fileRepository->findBy(['bucket' => 'mybucket'], [], null, 1);
```

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`
    Only `find` never modify the internal pointer.

This is another example for retrieving all files of the connected user:

```
$truncated = []
do {
   $objects = $fileRepository->findBy([], [], null, $truncated ? 1 : 0);
   // Do something with objects
   $truncated = $objects->getBucketsTruncated();
} while ($truncated);
```

Note that you can use `findAll` on the first call too.

Finally, the `findByFrom` method returns files starting **after** the given identifier:

```
$objects = $fileRepository->findByFrom(['bucket' => 'mybucket'], ['mybucket' => 'myid3']);
// Returns files myid4, myid5, myid6... but not myid3
// Since the criteria specifies the bucket, you can even simplify by: findByFrom(['bucket' => 'mybucket'], 'myid3')
```

Lazy load
---------

[](#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.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

5

Last Release

2643d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9fe350b054bd957825ec49c319f10ca11e925ed79e739a98a9651c68a037b671?d=identicon)[lvo](/maintainers/lvo)

---

Top Contributors

[![l-vo](https://avatars.githubusercontent.com/u/15314293?v=4)](https://github.com/l-vo "l-vo (95 commits)")[![emri99](https://avatars.githubusercontent.com/u/6652177?v=4)](https://github.com/emri99 "emri99 (1 commits)")

---

Tags

amazoncephdoctrineodmphps3

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/coffreo-ceph-odm/health.svg)

```
[![Health](https://phpackages.com/badges/coffreo-ceph-odm/health.svg)](https://phpackages.com/packages/coffreo-ceph-odm)
```

###  Alternatives

[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.1M11](/packages/bavix-laravel-wallet)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[leantime/leantime

Open source project management system for non-project managers. Simple like Trello, powerful like Jira. Built with neurodiversity in mind.

9.4k2.8k](/packages/leantime-leantime)[google/cloud-bigquery

BigQuery Client for PHP

8817.2M41](/packages/google-cloud-bigquery)[formal/orm

324.0k1](/packages/formal-orm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
