PHP code example of jackalope / jackalope-doctrine-dbal
1. Go to this page and download the library: Download jackalope/jackalope-doctrine-dbal library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jackalope / jackalope-doctrine-dbal example snippets
// 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);
// 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();
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);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.