gmoigneu / laravel-jackrabbit by gmoigneu

Laravel 5.x package providing Jackrabbit backend capabilities with Doctrine-PHPCR-ODM mappings
0
1
2
Package Data
Maintainer Username: gmoigneu
Maintainer Contact: guillaume@moigneu.net (Guillaume Moigneu)
Package Create Date: 2015-11-08
Package Last Update: 2015-11-08
Language: PHP
License: MIT
Last Refreshed: 2024-11-30 03:03:31
Package Statistics
Total Downloads: 0
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Laravel 5.x package providing Jackrabbit backend capabilities with Doctrine-PHPCR-ODM mappings.

Prerequisites

  • Apache Sling 7 or Apache Jackrabbit 2.3.6+

Jackalope is currently not working with Jackrabbit Oak and thus not in Apache Sling 8

Download Sling Launchpad 7 on Maven repository.

More info on :

  • https://sling.apache.org/news/sling-launchpad-8-released.html
  • https://github.com/jackalope/jackalope-jackrabbit/issues/98#issuecomment-154832686

Installation

composer require gmoigneu/laravel-jackrabbit

Configuration

Publish the config file & edit it with your Jackrabbit details:

php artisan vendor:publish

Usage

JCR Session

// Init session
$session = \App::make('phpcr.session');

// Save a new testNode
$rootNode = $session->getNode("/");
$testNode = $rootNode->addNode("testNode");
$session->save();

// Get the newly created node
$testNode = $session->getNode("/testNode");
dd($testNode);

Document Manager

Create a new model :

<?php namespace App\Models;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;

/**
 * @PHPCR\Document(referenceable=true)
 */
class Post
{

    /**
     * @PHPCR\Uuid()
     */
    protected $uuid;

    /**
     * @PHPCR\Id()
     */
    protected $slug;

    /**
     * @PHPCR\ParentDocument()
     */
    protected $parent;

    /**
     * @PHPCR\NodeName
     */
    protected $title;

    public function setParent($parent)
    {
        $this->parent = $parent;
        return $this;
    }

    public function setTitle($title)
    {
        $this->title = $title;
        return $this;
    }

    public function getTitle()
    {
        return $this->title;
    }

}

Register your new type with :

$ php artisan doctrine:phpcr:register-system-node-types                                                                     
Successfully registered system node types.

Use your model wherever you want :

// Get the document manager
$dm = \App::make('phpcr.manager');

// Get the root node
$root = $dm->find(null, '/');

// Create a post
$post = new Post();
$post->setParent($root);
$post->setTitle('Example Post');

$dm->persist($post);
$dm->flush();

$post = $dm->find(null, 'Example Post');
dd($post);

Credits

Based on the work of Workers