First Symfony2 CMF based CMS: PagesBundle & CMF-Sandbox!

Update note:

There is the doctrine phpcr-odm layer that maps phpcr repositories to documents. The phpcr layer itself will be mostly relevant to people working on improving the doctrine layer, and maybe for advanced features in the cmf bundles. But for users of the cmf, the phpcr layer is like the sql api – you don’t need to touch it.

Here i will record my experience trying the first Symfony2 CMF based CMS PagesBundle from here:
http://melp.nl/2011/07/symfony2-phpcr-doctrine2-jackalope-recipe

So before I proceed further I was mentored by dbu some and I decided to first focus on the installation of the jackalope, jackrabbit cr server and phpcrbrowser.
The only issue I had with jackrabbit cr was that i had to run it with a port defined as I was already using jenkins on the same port:

java -jar jackrabbit-standalone-*.jar --port 8888

Then i ran into an error for phpcrbrowser but it was because that had not been updated or synced with the latest developments for jackalope so I had to:

cd ext/jackalope
git reset --hard 914c14ade72c9c94c02f269286006c26c98273c9
git submodule update
Submodule path 'api-test/suite': checked out '7c0c8d595e2c7247eb2d062fa15c4b5e03f35683'
Submodule path 'lib/phpcr': checked out '2eab6944842ddbaa94f9851557001a90e4c79a98'

Then phpcrbrowser was wrought back to life. In addition to this of course i did adjustments for the port and domain for my jackrabbit installation on www/index.php.

Once you are done with jackrabbit and the phpcrbrowser then do not move into tests as it is shown here as the tests for jackalope are not interesting for the cmf and the ones in sandbox are currently broken.

So for our first encounter with phpcr here we have a diagram of a use case:

The repository in phpcr is the entry point to get a session as shown in the diagram, the representation of the backend, in phpcr lingo, is the workspace. First we get the repository from the factory configured according certain parameters. Then we use the repository thus created to authenticate by login into the repository. The repository in turn returns to us a session from which we can operate thereby creating nodes, setting its properties, persisting them, and fetching them again for further processing.

1
2
3
4
5
6
7
8
9
10
11
12
$factoryclass = '\Jackalope\RepositoryFactoryJackrabbit';
$parameters = array('jackalope.jackrabbit_uri' => 'http://localhost:8080/server'); //end of implementation specific configuration
$factory = new $factoryclass();
$repository = $factory->getRepository($parameters);
$credentials = new \PHPCR\SimpleCredentials('admin','admin');
$session = $repository->login($credentials, 'default);
$node = $session->addNode('test', 'nt:unstructured');
$node->setProperty('prop', 'value');
$session->save();
...
$node = $session->getNode('/test');
echo $node->getPropertyValue('prop');

Ok so after a rapid intro to some phpcr code, we now turn to start with the cmf-sandbox. The cmf-sandbox is the test project that tries to demo the integration for all the phpcr components for a symfony2 project.

We now setup the project, register node types for phpcr and load fixtures:

git clone git://github.com/symfony-cmf/cmf-sandbox.git
cd cmf-sandbox
bin/vendors install
cp app/config/parameters.ini.dist app/config/parameters.ini
gedit app/config/parameters.ini
bin/vendors update
app/console doctrine:phpcr:register-system-node-types
app/console -v phpcr:fixtures:load --path=src/Sandbox/MainBundle/Resources/data/fixtures/ --purge=true

Because the documentation I saw on github told me to play adding or populating some info on my jackrabbit server I did and now I am getting this error while loading the fixtures:

[PHPCR\PathNotFoundException] 
HTTP 404 Path Not Found: DELETE array ( 
'/edu[2]' => 'http://localhost:8888/server/default/jcr:root/edu[2]', 
)

and now trying to do a purge stuck on this:

  [ErrorException]                                                                                                                                                                                                                          
  Notice: Undefined property: Symfony\Cmf\Bundle\PhpcrCommandsBundle\Command\PurgeCommand::$container in /home/cordoval/sites-2/cmf-sandbox/vendor/symfony-cmf/src/Symfony/Cmf/Bundle/PhpcrCommandsBundle/Command/PhpcrCommand.php line 38

There was another problem that I resolved by shutting down the java process and removing the jackrabbit subfolder that gets generated by the server.

Also make sure you have to place your vhost folder to be served starting at the cmf-symfony/web level, else you will have problems with loading the css and other assets files.

What is the next step?

Try to work on this issues here and help us with the symfony2 cmf effort:
https://github.com/symfony-cmf/symfony-cmf/issues

4 thoughts on “First Symfony2 CMF based CMS: PagesBundle & CMF-Sandbox!

  1. i want to build a music site with a symfony cms i hope this project getting fast progress so i can go on with my qeust to bring great music too all kind of people out there
    my friend tries programming but its slow progress because he does not always know how to connect it all
    and my php skillzzzzz are down below 0

    so i hope this project comes along fast

    looking forward to see what gonna be next

  2. Doesn’t this put me at a disadvantage since now my cms based on symfony-cmf is dependent on java inaddition to php. This makes installation lot more messy, not to mention most hosts don’t give you java with php.

    How am I suppose to convince my users that this complicated system is better than the usual just php system?

    Can you talk more about his

    • I don’t think this is for users who don’t understand the power of PHPCR. So your question is just really because it is just not in the last state. But it will get there. I need to come back and blog on the latest developments. Until then.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>