PHPackages                             jackalope/jackalope-doctrine-dbal - 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. jackalope/jackalope-doctrine-dbal

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

jackalope/jackalope-doctrine-dbal
=================================

Jackalope Transport library for Doctrine DBAL

2.0.3(5mo ago)1503.0M↓11%61[32 issues](https://github.com/jackalope/jackalope-doctrine-dbal/issues)[7 PRs](https://github.com/jackalope/jackalope-doctrine-dbal/pulls)20MITPHPPHP ^8.0CI passing

Since May 7Pushed 5mo ago11 watchersCompare

[ Source](https://github.com/jackalope/jackalope-doctrine-dbal)[ Packagist](https://packagist.org/packages/jackalope/jackalope-doctrine-dbal)[ Docs](http://jackalope.github.io)[ RSS](/packages/jackalope-jackalope-doctrine-dbal/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (76)Used By (20)Security (1)

Jackalope Doctrine-DBAL
=======================

[](#jackalope-doctrine-dbal)

[![Build Status](https://github.com/jackalope/jackalope-doctrine-dbal/actions/workflows/test-application.yaml/badge.svg?branch=2.x)](https://github.com/jackalope/jackalope-doctrine-dbal/actions/workflows/test-application.yaml)[![Latest Stable Version](https://camo.githubusercontent.com/27a4cd2e59ad9f8c66949729f11f6f8b27c5ff2d44dec3a798391270c675917e/68747470733a2f2f706f7365722e707567782e6f72672f6a61636b616c6f70652f6a61636b616c6f70652d646f637472696e652d6462616c2f76657273696f6e2e706e67)](https://packagist.org/packages/jackalope/jackalope-doctrine-dbal)[![Total Downloads](https://camo.githubusercontent.com/2ae3c94ef29052eb48e9d536d945ded28f494372aa28cc7fc112c06e490350a5/68747470733a2f2f706f7365722e707567782e6f72672f6a61636b616c6f70652f6a61636b616c6f70652d646f637472696e652d6462616c2f642f746f74616c2e706e67)](https://packagist.org/packages/jackalope/jackalope-doctrine-dbal)

Implementation of the PHP Content Repository API ([PHPCR](http://phpcr.github.io)) using a relational database to persist data.

Jackalope uses Doctrine DBAL to abstract the database layer. It is currently tested to work with MySQL, PostgreSQL and SQLite.

For the moment, it is less feature complete, performant and robust than [Jackalope-Jackrabbit](http://github.com/jackalope/jackalope-jackrabbit) but it can run on any server with PHP and an SQL database.

Discuss on  or visit #jackalope on irc.freenode.net

License
-------

[](#license)

This code is dual licensed under the MIT license and the Apache License Version 2.0. Please see the file LICENSE in this folder.

Requirements
============

[](#requirements)

- PHP version: See composer.json
- One of the following databases, including the PDO extension for it:
    - MySQL &gt;= 5.1.5 (we need the ExtractValue function)
    - PostgreSQL
    - SQLite
    - Oracle

Installation
============

[](#installation)

The recommended way to install jackalope is through [composer](http://getcomposer.org/).

```
$ mkdir my-project
$ cd my-project
$ composer init
$ composer require jackalope/jackalope-doctrine-dbal
```

Create a repository
-------------------

[](#create-a-repository)

Set up a new database supported by Doctrine DBAL. You can use your favorite GUI frontend or use the following commands:

### MySQL

[](#mysql)

Note that you need at least version 5.1.5 of MySQL, otherwise you will get `SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION cmf-app.EXTRACTVALUE does not exist`

```
mysqladmin -u root -p  create database jackalope
echo "grant all privileges on jackalope.* to 'jackalope'@'localhost' identified by '1234test'; flush privileges;" | mysql -u root -p
```

Also note that with MySQL/MariaDB, you need to configure the encoding to be used (see "bootstrapping" below).

If you configured the encoding but still run into issues with the encoding, e.g. `SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'`, you can set the `jackalope.case_sensitive_encoding` parameter in the call to `RepositoryFactoryDoctrineDBAL::getRepository`.

### PostgreSQL

[](#postgresql)

```
psql -c "CREATE ROLE jackalope WITH ENCRYPTED PASSWORD '1234test' NOINHERIT LOGIN;" -U postgres
psql -c "CREATE DATABASE jackalope WITH OWNER = jackalope;" -U postgres
```

### SQLite

[](#sqlite)

Database is created automatically if you specify driver and path ("pdo\_sqlite", "jackalope.db"). Database name is not needed.

For further details, please see the [Doctrine configuration page](http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connection-details).

### Oracle

[](#oracle)

Disclaimer: There is no continuous integration with Oracle. Jackalope 1.8.0 was successfully tested by one of our users against `Oracle 19c Enterprise Edition`. If you plan to use Jackalope with an Oracle Database, we recommend that you set up the Jackalope test suite to ensure your version of Jackalope and Oracle work together nicely.

Note: A doctrine middleware is automatically added to the database connection to work around Oracle converting the lowercase table and field names to upper case in its results.

CLI Tool
--------

[](#cli-tool)

We provide a couple of useful commands to interact with the repository.

NOTE: If you are using PHPCR with the **Symfony** framework, the `DoctrinePHPCRBundle` provides the commands in the normal Symfony console. Only do the below setup if you use Jackalope without the Symfony integration.

To use the console, copy `cli-config.dist.php` to `cli-config.php` and configure the connection parameters. Then you can run the commands from the jackalope directory with `./bin/jackalope`

There is the Jackalope specific command `jackalope:init:dbal` which you need to run to initialize a database before you can use it.

You have many useful commands available from the phpcr-utils. To get a list of all commands, type:

```
$ ./bin/jackalope
```

To get more information on a specific command, use the `help` command. To learn more about the `phpcr:workspace:export` command for example, you would type:

```
$ ./bin/jackalope help phpcr:workspace:export
```

Bootstrapping
=============

[](#bootstrapping)

Before you can use Jackalope with a database, you need to prepare the database. Create a database as described above, then make sure the command line utility is set up (see above "CLI Tool"). Now you can run:

```
$ bin/jackalope jackalope:init:dbal
```

Once these steps are done, you can bootstrap the library. A minimalist sample code to get a PHPCR session with the doctrine-dbal backend:

```
// For further details, please see Doctrine configuration page.
// http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connection-details

use Doctrine\DBAL\DriverManager;
use Jackalope\RepositoryFactoryDoctrineDBAL;
use PHPCR\SimpleCredentials;

$driver    = 'pdo_mysql'; // pdo_pgsql | pdo_sqlite
$host      = 'localhost';
$user      = 'admin'; // only used for recording information about the node creator
$sqluser   = 'jackalope';
$sqlpass   = 'xxxx';
$database  = 'jackalope';
// $path      = 'jackalope.db'; // for SQLite
$workspace = 'default';
$charset   = 'utf8mb4'; // only for MySQL/MariaDB

// Bootstrap Doctrine
$connection = DriverManager::getConnection([
    'driver'    => $driver,
    'host'      => $host,
    'user'      => $sqluser,
    'password'  => $sqlpass,
    'dbname'    => $database,
    // 'path'   => $path, // for SQLite
    'charset    => $charset, // only for MySQL/MariaDB
]);

$factory = new RepositoryFactoryDoctrineDBAL();
$repository = $factory->getRepository(
    ['jackalope.doctrine_dbal_connection' => $connection]
);

// Dummy credentials to comply with the API
$credentials = new SimpleCredentials($user, null);
$session = $repository->login($credentials, $workspace);
```

To use a workspace different than `default` you need to create it first. To create a new workspace, run the command `bin/jackalope phpcr:workspace:create `. You can also use the PHPCR API to create workspaces from your code.

Usage
=====

[](#usage)

The entry point is to create the repository factory. The factory specifies the storage backend as well. From this point on, there are no differences in the usage (except for supported features, that is).

```
// See Bootstrapping for how to get the session.

$rootNode = $session->getNode('/');
$whitewashing = $rootNode->addNode('www-whitewashing-de');

$session->save();

$posts = $whitewashing->addNode('posts');

$session->save();

$post = $posts->addNode('welcome-to-blog');

$post->addMixin('mix:title');
$post->setProperty('jcr:title', 'Welcome to my Blog!');
$post->setProperty('jcr:description', 'This is the first post on my blog! Do you like it?');

$session->save();
```

See [PHPCR Tutorial](http://phpcr.readthedocs.org/en/latest/book/index.html)for a more detailed tutorial on how to use the PHPCR API.

Performance tweaks
==================

[](#performance-tweaks)

If you know that you will need many child nodes of a node you are about to request, use the depth hint on Session::getNode. This will prefetch the children to reduce the round trips to the database. It is part of the PHPCR standard. You can also globally set a fetch depth, but that is Jackalope specific: Call Session::setSessionOption with Session::OPTION\_FETCH\_DEPTH to something bigger than 1.

Use Node::getNodeNames if you only need to know the names of child nodes, but don't need the actual nodes. Note that you should not use the typeFilter on getNodeNames with jackalope. Using the typeFilter with getNodes to only fetch the nodes of types that interest you can make a lot of sense however.

Advanced configuration
======================

[](#advanced-configuration)

Logging
-------

[](#logging)

Jackalope supports logging, for example to investigate the number and type of queries used. To enable logging, provide a logger instance to the repository factory:

```
use Jackalope\RepositoryFactoryDoctrineDBAL;
use Jackalope\Transport\Logging\DebugStack;

$factory = new RepositoryFactoryDoctrineDBAL();
$logger = new DebugStack();

$parameters = [
    'jackalope.doctrine_dbal_connection' => $connection,
    'jackalope.logger' => $logger,
];

$repository = $factory->getRepository($parameters);

//...

// at the end, output debug information
var_dump($logger->calls);
```

You can also wrap a [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)compatible logger like [monolog](https://github.com/Seldaek/monolog) with the Psr3Logger class.

Note that when using jackalope in Symfony2, the logger is integrated in the debug toolbar.

Custom UUID generator
---------------------

[](#custom-uuid-generator)

By default, Jackalope uses the UUIDHelper class from phpcr-utils. If you want to use something else, you can provide a closure that returns UUIDs as parameter `jackalope.uuid_generator` to `$factory->getRepository($parameters)`

Implementation notes
====================

[](#implementation-notes)

See [doc/architecture.md](https://github.com/jackalope/jackalope/blob/master/doc/architecture.md)for an introduction how Jackalope is built. Have a look at the source files and generate the phpdoc.

Running the tests
=================

[](#running-the-tests)

Jackalope-doctrine-dbal is integrated with the phpcr-api-tests suite that tests all PHPCR functionality.

If you want to run the tests, please see the [README file in the tests folder](https://github.com/jackalope/jackalope-doctrine-dbal/blob/master/tests/README.md).

Things left to do
=================

[](#things-left-to-do)

The best overview of what needs to be done are the skipped API tests. Have a look at [ImplementationLoader](https://github.com/jackalope/jackalope-doctrine-dbal/blob/master/tests/ImplementationLoader.php)to see what is currently not working and start hacking :-)

Also have a look at the issue trackers of this project and the base jackalope/jackalope.

Contributors
============

[](#contributors)

- Christian Stocker
- David Buchmann
- Tobias Ebnöther
- Roland Schilter
- Uwe Jäger
- Lukas Kahwe Smith
- Benjamin Eberlei
- Daniel Barsotti
- [and many others](https://github.com/jackalope/jackalope-doctrine-dbal/contributors)

###  Health Score

67

—

FairBetter than 100% of packages

Maintenance66

Regular maintenance activity

Popularity59

Moderate usage in the ecosystem

Community51

Growing community involvement

Maturity83

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~65 days

Recently: every ~127 days

Total

71

Last Release

170d ago

Major Versions

1.11.1 → 2.0.0-beta32024-01-08

1.11.2 → 2.0.0-RC12024-02-16

1.12.0 → 2.0.02024-04-03

1.13.0 → 2.0.12024-05-07

1.x-dev → 2.0.32025-11-29

PHP version history (8 changes)1.0.0-alpha1PHP &gt;=5.3.2

1.0.0-beta2PHP &gt;=5.3.3

1.3.0PHP ^5.6|^7.0

1.4.0PHP ^7.1

1.6.0PHP ^7.3 || ^8.0

1.7.2PHP ^7.2 || ^8.0

2.0.0-beta1PHP ^7.4 || ^8.0

2.0.0-beta2PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76576?v=4)[David Buchmann](/maintainers/dbu)[@dbu](https://github.com/dbu)

![](https://avatars.githubusercontent.com/u/328359?v=4)[Luis Cordova](/maintainers/cordoval)[@cordoval](https://github.com/cordoval)

![](https://avatars.githubusercontent.com/u/20873?v=4)[Luke Smith](/maintainers/lsmith)[@lsmith](https://github.com/lsmith)

---

Top Contributors

[![dbu](https://avatars.githubusercontent.com/u/76576?v=4)](https://github.com/dbu "dbu (754 commits)")[![lsmith77](https://avatars.githubusercontent.com/u/300279?v=4)](https://github.com/lsmith77 "lsmith77 (506 commits)")[![beberlei](https://avatars.githubusercontent.com/u/26936?v=4)](https://github.com/beberlei "beberlei (97 commits)")[![ebi](https://avatars.githubusercontent.com/u/11541?v=4)](https://github.com/ebi "ebi (93 commits)")[![Seldaek](https://avatars.githubusercontent.com/u/183678?v=4)](https://github.com/Seldaek "Seldaek (73 commits)")[![lapistano](https://avatars.githubusercontent.com/u/95115?v=4)](https://github.com/lapistano "lapistano (63 commits)")[![cryptocompress](https://avatars.githubusercontent.com/u/1130433?v=4)](https://github.com/cryptocompress "cryptocompress (54 commits)")[![chregu](https://avatars.githubusercontent.com/u/47106?v=4)](https://github.com/chregu "chregu (49 commits)")[![rndstr](https://avatars.githubusercontent.com/u/32963?v=4)](https://github.com/rndstr "rndstr (46 commits)")[![nicam](https://avatars.githubusercontent.com/u/182071?v=4)](https://github.com/nicam "nicam (39 commits)")[![dantleech](https://avatars.githubusercontent.com/u/530801?v=4)](https://github.com/dantleech "dantleech (36 commits)")[![petesiss](https://avatars.githubusercontent.com/u/235621?v=4)](https://github.com/petesiss "petesiss (31 commits)")[![adou600](https://avatars.githubusercontent.com/u/1431387?v=4)](https://github.com/adou600 "adou600 (24 commits)")[![alexander-schranz](https://avatars.githubusercontent.com/u/1698337?v=4)](https://github.com/alexander-schranz "alexander-schranz (16 commits)")[![uwej711](https://avatars.githubusercontent.com/u/648874?v=4)](https://github.com/uwej711 "uwej711 (15 commits)")[![justinrainbow](https://avatars.githubusercontent.com/u/86520?v=4)](https://github.com/justinrainbow "justinrainbow (13 commits)")[![pavelvondrasek](https://avatars.githubusercontent.com/u/7081340?v=4)](https://github.com/pavelvondrasek "pavelvondrasek (9 commits)")[![lex009](https://avatars.githubusercontent.com/u/1351919?v=4)](https://github.com/lex009 "lex009 (7 commits)")[![esserj](https://avatars.githubusercontent.com/u/1032205?v=4)](https://github.com/esserj "esserj (6 commits)")[![wouterj](https://avatars.githubusercontent.com/u/749025?v=4)](https://github.com/wouterj "wouterj (4 commits)")

---

Tags

doctrine-dbalphpcrtransport implementation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jackalope-jackalope-doctrine-dbal/health.svg)

```
[![Health](https://phpackages.com/badges/jackalope-jackalope-doctrine-dbal/health.svg)](https://phpackages.com/packages/jackalope-jackalope-doctrine-dbal)
```

###  Alternatives

[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4485.3M4](/packages/martin-georgiev-postgresql-for-doctrine)[doctrine/phpcr-bundle

Symfony DoctrinePHPCRBundle

1602.6M41](/packages/doctrine-phpcr-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[jackalope/jackalope-jackrabbit

Jackalope Transport library for Jackrabbit

66912.1k30](/packages/jackalope-jackalope-jackrabbit)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[phpcr/phpcr-shell

Shell for PHPCR

721.3M8](/packages/phpcr-phpcr-shell)

PHPackages © 2026

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