PHP code example of dantleech / phpcr-generator

1. Go to this page and download the library: Download dantleech/phpcr-generator 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/ */

    

dantleech / phpcr-generator example snippets


    $converter = new NodeConverter($phpcrSession);
    $builder = new NodeBuilder('node', 'nt:unstructured');

    $builder->node('content', 'nt:unstructured')
            ->node('article1')
                ->property('title', 'My first article')
                ->property('body', 'My first article body')
            ->end()
            ->node('article2')
                ->property('title', 'My first article')
                ->property('body', 'My first article body')
            ->end()
        ->end();

    $this->converter->convert($this->builder);

    $phpcrSession->save();

        $builder->node('content-[1-5]', 'nt:unstructured')
            ->node('article[1-10]')
                ->property('title', 'My first article')
                ->property('body', 'My first article body')
            ->end()
        ->end();