PHP code example of jackalope / jackalope-jackrabbit

1. Go to this page and download the library: Download jackalope/jackalope-jackrabbit 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-jackrabbit example snippets


$jackrabbit_url = 'http://127.0.0.1:8080/server/';
$user           = 'admin';
$pass           = 'admin';
$workspace      = 'default';

$factory = new \Jackalope\RepositoryFactoryJackrabbit();
$repository = $factory->getRepository(
    array("jackalope.jackrabbit_uri" => $jackrabbit_url)
);
$credentials = new \PHPCR\SimpleCredentials($user, $pass);
$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();

$factory = new \Jackalope\RepositoryFactoryJackrabbit();
$logger = new Jackalope\Transport\Logging\DebugStack();
$options = array(
    'jackalope.jackrabbit_uri' => $jackrabbit_url,
    'jackalope.logger' => $logger,
);
$repository = $factory->getRepository($options);

...

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