gmoigneu / laravel-jackrabbit
Laravel 5.x package providing Jackrabbit backend capabilities with Doctrine-PHPCR-ODM mappings
dev-master
2015-11-08 16:10 UTC
Requires
- php: >=5.5.9
- doctrine/phpcr-odm: ^1.2
- jackalope/jackalope-jackrabbit: ^1.2
- laravel/framework: 5.1.*
This package is not auto-updated.
Last update: 2024-11-23 19:19:10 UTC
README
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
- jackalope/jackalope-jackrabbit#98 (comment)
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