Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…


Cannot retrieve contributors at this time

file 68 lines (47 sloc) 2.249 kb

Jackalope Doctrine Transport

The Jackalope Doctrine transport implements the PHPCR API with a database backend using Doctrine DBAL as access and abstraction layer.


You need both Jackalope with the DoctrineDBAL branch and Doctrine Common+DBAL installed on your machine.


// autoloading
require_once "path/to/doctrine-common/lib/Doctrine/Common/ClassLoader.php";
require_once "path/to/src/Jackalope/autoloader.php";

$loader = new \Doctrine\Common\ClassLoader("Doctrine\Common", "path/to/doctrine-common/lib");
$loader = new \Doctrine\Common\ClassLoader("Doctrine\DBAL", "path/to/doctrine-dbal/lib");

// Bootstrap Doctrine
$dbConn = \Doctrine\DBAL\DriverManager::getConnection(array(
    'driver'    => "pdo_mysql",
    'host'      => "localhost",
    'user'      => "root",
    'password'  => "",
    'dbname'    => "jackalope",

// only necessary on the first run, creates the database:
$schema = \Jackalope\Transport\Doctrine\RepositorySchema::create();
foreach ($schema->toSQL($dbConn->getDatabasePlatform()) AS $sql) {

// Create Jackalope
$transport = new \Jackalope\Transport\DoctrineDBAL\Client(new \Jackalope\Factory(), $dbConn);
$repository = new \Jackalope\Repository(null, null, $transport);

Creating your first Workspace

Using $transport from above you have to create the initial workspace:


Getting started

Now you have a 'default' workspace and can start changing stuff:


$session = $repository->login(new \PHPCR\SimpleCredentials("foo", "bar"), "default"); // credentials dont matter
$rootNode = $session->getNode("/");
$whitewashing = $rootNode->addNode("www-whitewashing-de");

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

$post = $posts->addNode("welcome-to-blog");
$post->setProperty("jcr:title", "Welcome to my Blog!");
$post->setProperty("jcr:description", "This is the first post on my blog!Do you like it?");

Something went wrong with that request. Please try again.