WARNING: You are browsing the documentation for version 1.0 which is not maintained anymore. If some of your projects are still using this version, consider upgrading.

Installing the CMF sandbox

1.0 version
Maintained Unmaintained

Installing the CMF sandbox

Caution

The cookbook is in the process of being restructured. Some documentation is outdated, notable configuration examples. If something does not work, please have a look in the Reference section and send pull requests to fix things, or just open an issue on github so that we know about the problem.

Refer to the documentation issues to help us bringing this article up to date.

Tip

The CMF sandbox github repository contains a README file with an up to date installation instruction.

This tutorial shows how to install the Symfony CMF Sandbox, a demo platform aimed at showing the tool's basic features running on a demo environment. This can be used to evaluate the platform or to see actual code in action, helping you understand the tool's internals.

While it can be used as such, this sandbox does not intend to be a development platform. If you are looking for installation instructions for a development setup, please refer to:

Requirements

As Symfony CMF Sandbox is based on Symfony2, you should make sure you meet the Requirements for running Symfony2. Git 1.6+, Curl and PHP Intl are also needed to follow the installation steps listed below.

For the PHPCR repository requirements, see PHPCR-ODM requirements

Installation

Apache Jackrabbit

The Symfony CMF Sandbox uses Jackalope with Apache JackRabbit by default. Alternative storage methods can be configured, but this is the most tested, and should be the easiest to setup.

You can get the latest Apache Jackrabbit version from the project's official download page. To start it, use the following command

1
$ java -jar jackrabbit-standalone-*.jar

By default the server is listening on the 8080 port, you can change this by specifying the port on the command line.

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

For unix systems, you can get the start-stop script for /etc/init.d here.

Getting the Sandbox Code

The Symfony CMF Sandbox source code is available on github. To get it use:

1
$ git clone git://github.com/symfony-cmf/cmf-sandbox.git

Move into the folder and copy the default configuration files:

1
2
3
$ cd cmf-sandbox
$ cp app/config/parameters.yml.dist app/config/parameters.yml
$ cp app/config/phpcr_jackrabbit.yml.dist app/config/phpcr.yml

These two files include the default configuration parameters for the sandbox storage mechanism. You can modify them to better fit your needs

Note

The second configuration file refers to specific jackalope + jackrabbit configuration. There are other files available for different stack setups.

Next, get composer and install and the necessary bundles (this may take a while):

1
2
3
4
5
# get composer
$ curl -s http://getcomposer.org/installer | php --

# install bundles
$ php composer.phar install

Note

On Windows you need to run the shell as Administrator or edit the composer.json and change the line "symfony-assets-install": "symlink" to "symfony-assets-install": "". If you fail to do this you might receive:

1
2
3
[Symfony\Component\Filesystem\Exception\IOException]
Unable to create symlink due to error code 1314: 'A required privilege is not held
by the client'. Do you have the required Administrator-rights?

Preparing the PHPCR Repository

Now that you have all the code, you need to setup your PHPCR repository. PHPCR organizes data in workspaces and sandbox uses the "default" workspace, which is exists by default in Jackrabbit. If you use other applications that require Jackrabbit or if you just wish to change the workspace name, you can do so in app/config/phpcr.yml. The following command will create a new workspace named "sandbox" in Jackrabbit. If you decide to use the "default" workspace, you can skip it.

1
$ php app/console doctrine:phpcr:workspace:create sandbox

Once your workspace is set up, you need to register the node types for phpcr-odm:

1
$ php app/console doctrine:phpcr:repository:init

Import the Fixtures

The sandbox provides a set of demo content to show various use cases. They are loaded using the fixture loading concept of PHPCR-ODM.

1
$ php app/console -v doctrine:phpcr:fixtures:load

This command loads fixtures from all bundles that provide them in the DataFixtures/PHPCR folder. The sandbox has fixtures in the MainBundle. Note that loading fixtures from non-default locations is possible as well, just not needed in this case.

Accessing your Sandbox

The sandbox should now be accessible on your web server.

1
http://localhost/app_dev.php

In order to run the sandbox in production mode you need to generate the doctrine proxies and dump the assetic assets:

1
2
$ php app/console cache:clear --env=prod --no-debug
$ php app/console assetic:dump --env=prod --no-debug

Alternative Storage Mechanisms

Symfony CMF and the sandbox are storage agnostic, which means you can change the storage mechanism without having to change your code. The default storage mechanism for the sandbox is Jackalope + Apache Jackrabbit, as it's the most tested and stable setup. However, other alternatives are available.

Jackalope + Doctrine DBAL

Note

By default, when using Doctrine DBAL, data is stored using a Sqlite database. Refer to the project's page for installation instructions. If you wish to use other database systems, change the configuration parameters in app/config/parameters.yml. Refer to Symfony's page on Doctrine DBAL configuration or Doctrine's documentation for more information.

Move into the sandbox folder and copy the default configuration file for Doctrine DBAL setup:

1
2
$ cd cmf-sandbox
$ cp app/config/phpcr_doctrine_dbal.yml.dist app/config/phpcr.yml

Next, you need to install the actual Doctrine DBAL bundle required by jackalope:

1
$ php composer.phar require jackalope/jackalope-doctrine-dbal:1.0.*

And create and init your database:

1
2
$ php app/console doctrine:database:create
$ php app/console doctrine:phpcr:init:dbal

After this, your should follow the steps in Preparing the PHPCR repository.

Doctrine caching

Optionally, to improve performance, you can install DoctrineCacheBundle by typing the following command:

1
$ php composer.phar require doctrine/cache-bundle:1.0.*

And adding the following entry to your app/AppKernel.php:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// app/AppKernel.php

// ...
public function registerBundles()
{
  $bundles = array(
      // ...
      new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
      // ...
  );
}

Finally, uncomment the caches settings in the phpcr.yml as well as the doctrine_cache settings in config.yml.

1
2
3
4
# app/config/phpcr.yml
caches:
    meta: doctrine_cache.providers.phpcr_meta
    nodes: doctrine_cache.providers.phpcr_nodes
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# app/config/config.yml

# ...

doctrine_cache:
    providers:
        phpcr_meta:
            type: file_system
        phpcr_nodes:
            type: file_system

Midgard2 PHPCR Provider

If you want to run the CMF sandbox with the Midgard2 PHPCR provider instead of Jackrabbit, you need to install the midgard2 PHP extension. On current Debian/Ubuntu systems, this is simply done with:

1
$ sudo apt-get install php5-midgard2

On OS X you can install it using either Homebrew with:

1
$ brew install midgard2-php

or MacPorts with:

1
$ sudo port install php5-midgard2

You also need to download the midgard_tree_node.xml and midgard_namespace_registery.xml schema files and place them into <your-midgard2-folder>/schema (defaults to "/usr/share/midgard2/schema")

To have the Midgard2 PHPCR implementation installed run the following additional command:

1
$ php composer.phar require midgard/phpcr:dev-master

Finally, switch to one of the Midgard2 configuration file:

1
$ cp app/config/phpcr_midgard_mysql.yml.dist app/config/phpcr.yml

or:

1
$ cp app/config/phpcr_midgard_sqlite.yml.dist app/config/phpcr.yml

After this, your should follow the steps in Preparing the PHPCR repository to continue the installation process.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.