2017 © Pedro PelĂĄez
 

library jackalope-doctrine-dbal

Jackalope Transport library for Doctrine DBAL

image

jackalope/jackalope-doctrine-dbal

Jackalope Transport library for Doctrine DBAL

  • Tuesday, July 10, 2018
  • by cordoval
  • Repository
  • 14 Watchers
  • 86 Stars
  • 753,601 Installations
  • PHP
  • 142 Dependents
  • 14 Suggesters
  • 52 Forks
  • 43 Open issues
  • 43 Versions
  • 4 % Grown

The README.md

Jackalope Doctrine-DBAL

Build Status Latest Stable Version Total Downloads, (*1)

Implementation of the PHP Content Repository API (PHPCR) using a relational database to persist data., (*2)

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

For the moment, it is less feature complete, performant and robust than Jackalope-Jackrabbit but it can run on any server with PHP and an SQL database., (*4)

Discuss on jackalope-dev@googlegroups.com or visit #jackalope on irc.freenode.net, (*5)

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., (*6)

Requirements

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

Installation

The recommended way to install jackalope is through composer., (*7)

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

Create a repository

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

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, (*9)

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)., (*10)

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., (*11)

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

Database is created automatically if you specify driver and path ("pdo_sqlite", "jackalope.db"). Database name is not needed., (*12)

For further details, please see the Doctrine configuration page., (*13)

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., (*14)

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., (*15)

CLI Tool

We provide a couple of useful commands to interact with the repository., (*16)

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., (*17)

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, (*18)

There is the Jackalope specific command jackalope:init:dbal which you need to run to initialize a database before you can use it., (*19)

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

$ ./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:, (*21)

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

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:, (*22)

$ 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:, (*23)

// 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 <myworkspace>. You can also use the PHPCR API to create workspaces from your code., (*24)

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)., (*25)

// 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 for a more detailed tutorial on how to use the PHPCR API., (*26)

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., (*27)

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., (*28)

Advanced configuration

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:, (*29)

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 compatible logger like monolog with the Psr3Logger class., (*30)

Note that when using jackalope in Symfony2, the logger is integrated in the debug toolbar., (*31)

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), (*32)

Implementation notes

See doc/architecture.md for an introduction how Jackalope is built. Have a look at the source files and generate the phpdoc., (*33)

Running the tests

Jackalope-doctrine-dbal is integrated with the phpcr-api-tests suite that tests all PHPCR functionality., (*34)

If you want to run the tests, please see the README file in the tests folder., (*35)

Things left to do

The best overview of what needs to be done are the skipped API tests. Have a look at ImplementationLoader to see what is currently not working and start hacking :-), (*36)

Also have a look at the issue trackers of this project and the base jackalope/jackalope., (*37)

Contributors

The Versions

10/07 2018

dev-master

9999999-dev http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

03/05 2018

dev-doctrine-dbal-2.7

dev-doctrine-dbal-2.7 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

29/01 2018

1.3.2

1.3.2.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

29/01 2018

dev-bugifx/utf8-mb4

dev-bugifx/utf8-mb4 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

22/11 2017

1.3.1

1.3.1.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

07/04 2017

1.3.0

1.3.0.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

04/03 2017

dev-allow_overwriting_uuid

dev-allow_overwriting_uuid http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

09/06 2016

1.2.8

1.2.8.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

25/04 2016

1.2.7

1.2.7.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

29/03 2016

dev-node_was_deleted

dev-node_was_deleted http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

25/03 2016

1.2.6

1.2.6.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

22/01 2016

1.2.5

1.2.5.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

22/01 2016
23/12 2015
20/10 2015

1.2.4

1.2.4.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

18/10 2015

1.2.3

1.2.3.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

25/06 2015

1.2.x-dev

1.2.9999999.9999999-dev http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

25/06 2015
29/05 2015

dev-cache_queries_node_types

dev-cache_queries_node_types http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

25/05 2015

1.1.x-dev

1.1.9999999.9999999-dev http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

07/05 2015
02/05 2015

1.1.5

1.1.5.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

02/05 2015
02/05 2015

1.1.4

1.1.4.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

01/05 2015

1.1.3

1.1.3.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

01/05 2015

dev-hhvm

dev-hhvm http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

05/04 2015

1.2.0-RC1

1.2.0.0-RC1 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

07/08 2014

1.1.2

1.1.2.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

04/04 2014

1.1.1

1.1.1.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

27/02 2014

dev-join-on-issamenode

dev-join-on-issamenode http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

02/02 2014

1.1.0

1.1.0.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

08/01 2014

1.1.0-RC1

1.1.0.0-RC1 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

14/12 2013

1.0.x-dev

1.0.9999999.9999999-dev http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

10/10 2013

1.0.0

1.0.0.0 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

09/10 2013

1.0.0-RC4

1.0.0.0-RC4 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

06/10 2013

1.0.0-RC3

1.0.0.0-RC3 http://jackalope.github.io

Jackalope Transport library for Doctrine DBAL

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal phpcr transport implementation

02/10 2013

1.0.0-RC2

1.0.0.0-RC2 http://jackalope.github.io

Jackalope Transport library

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal transport implementation

25/09 2013

1.0.0-RC1

1.0.0.0-RC1 http://jackalope.github.io

Jackalope Transport library

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal transport implementation

11/09 2013

1.0.0-beta4

1.0.0.0-beta4 http://jackalope.github.io

Jackalope Transport library

  Sources   Download

MIT Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal transport implementation

31/07 2013

1.0.0-beta3

1.0.0.0-beta3 http://jackalope.github.com

Jackalope Transport library

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

doctrine-dbal transport implementation

11/07 2013

1.0.0-beta2

1.0.0.0-beta2 http://jackalope.github.com

Jackalope Transport library

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine-dbal transport implementation

12/06 2013

1.0.0-beta1

1.0.0.0-beta1 http://jackalope.github.com

Jackalope Transport library

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine-dbal transport implementation

07/05 2013

1.0.0-alpha1

1.0.0.0-alpha1 http://jackalope.github.com

Jackalope Transport library

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine-dbal transport implementation