PHPackages                             nitronet/ezormbundle - 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. nitronet/ezormbundle

ActiveLibrary

nitronet/ezormbundle
====================

Doctrine-like ORM for eZ Platform

20PHP

Since Oct 3Pushed 8y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

eZORMBundle
===========

[](#ezormbundle)

This bundle tries to provide an ORM-like PHP API to Query and Manage Content stored in eZ Platform. The main purpose is to ease the Symfony Developer's life by providing classic Symfony+Doctrine features like Entities, Forms, Validation... Here is a list of the main features:

- Fluent Query API
- Entity mapping to eZ Content
- Form builders
- ContentType migrations (like doctrine:schema:update)

Obviously this added abstraction layer isn't designed for performance. eZ, like any other Symfony application, requires proper HTTP caching and a decent environment configuration to perform at its best. We still consider performance as a key feature but we are aware that this ORM-thing will not perform as fast as raw eZ API usage, and you should be aware of this too.

This bundle is just a handy toolkit when building Forms, querying the API and manage ContentTypes. The API is SQL-oriented for ease of use and fast learning curve but the Content model of eZ Platform isn't SQL which leads to some limitations or differences:

- A Content (sql: row) can have different values with the same ID (versions, translations)
- A ContentType can be considered like a SQL table when doing a SELECT but writes are sometime requiring a Location (INSERT) and/or a special state (UPDATE)
- "Persistence" is a lie (but no one really cares)

Query example
-------------

[](#query-example)

Classic eZ Query:

```
use eZ\Publish\API\Repository\Values\Content\Query as eZQ;

$query = new \eZ\Publish\API\Repository\Values\Content\Query();
$query->limit = 5;
$query->offset = 10;
$query->filter = new eZQ\Criterion\LogicalAnd(array(
    new eZQ\Criterion\ContentTypeIdentifier('article'),
    new eZQ\Criterion\Visibility(eZQ\Criterion\Visibility::VISIBLE)
));
$query->sortClauses = array(new eZQ\SortClause\DateModified());

$results = $this->get('ezpublish.api.service.search')->findContent($query);

$articles = array();
foreach ($results->searchHits as $searchHit) {
    $articles[] = $searchHit->valueObject;
}
```

eZORM Query:

```
use eZ\Publish\API\Repository\Values\Content\Query as eZQ;
use Nitronet\eZORMBundle\ORM\Query;

$query = new Query();
$query->select()
    ->where(new eZQ\Criterion\ContentTypeIdentifier('article'))
    ->andWhere(new eZQ\Criterion\Visibility(eZQ\Criterion\Visibility::VISIBLE))
    ->limit("10,5")
    ->orderBy(new eZQ\SortClause\DateModified())
;

$articles = $this->get('ezorm.connection')->execute($query);
```

ORM Magic
---------

[](#orm-magic)

The above example will return `stdClass` instances. To return custom entities ("Content Types") we just have to map them just like we commonly do with Doctrine.

```
