Installing the Standard Edition
Installing the Standard Edition¶
The Symfony CMF Standard Edition (SE) is a distribution based on all the main components needed for most common use cases.
The goal of this tutorial is to install the CMF bundles, with the minimum necessary configuration and some very simple examples, into a working Symfony2 application.
After that, you get a quick introduction of the bundles you have installed. This can be used to familiarize yourself with the CMF or as a starting point for a new custom application.
As Symfony CMF is based on Symfony2, you should make sure you meet the
Requirements for running Symfony2. Additionally, you need to have SQLite
PDO extension (
pdo_sqlite) installed, since it is used as the default
By default, Symfony CMF uses Jackalope + Doctrine DBAL and SQLite as the underlying DB. However, Symfony CMF is storage agnostic, which means you can use one of several available data storage mechanisms without having to rewrite your code. For more information on the different available mechanisms and how to install and configure them, refer to Installing and Configuring Doctrine PHPCR-ODM
You can install the Standard Edition in 2 ways:
The easiest way to install Symfony CMF is is using Composer. Get it using
$ curl -sS https://getcomposer.org/installer | php $ sudo mv composer.phar /usr/local/bin/composer
and then get the Symfony CMF code with it (this may take a while):
$ php composer.phar create-project symfony-cmf/standard-edition <path-to-install> $ cd <path-to-install>
<path-to-install> should either inside your web server doc
root or configure a virtual host for
This will clone the Standard Edition and install all the dependencies and run
some initial commands. These commands require write permissions to the
app/logs directory. In case the final commands end up
giving permissions errors, please follow the guidelines in the Symfony Book
to configure the permissions and then run the
$ php composer.phar install
You can also install the Standard Edition using GIT. Just clone the repository from github:
$ git clone git://github.com/symfony-cmf/symfony-cmf-standard.git <path-to-install> $ cd <path-to-install>
You still need Composer to get the dependencies. To install or update the
dependencies, use the
$ php composer.phar install
Set up the Database¶
The next step is to set up the database. If you want to use SQLite as your database backend just go ahead and run the following:
1 2 3 4
$ php app/console doctrine:database:create $ php app/console doctrine:phpcr:init:dbal $ php app/console doctrine:phpcr:repository:init $ php app/console doctrine:phpcr:fixtures:load
The first command will create a file called
app.sqlite inside your app
folder, containing the database content. The two commands after it will setup
PHPCR and the final command will load some fixtures, so you can access the
Standard Edition using a web server.
The project should now be accessible on your web server. If you have PHP 5.4 installed you can alternatively use the PHP internal web server:
$ php app/console server:run
And then access the CMF via:
The proper term to use for the default database of the CMF is content repository. The idea behind this name is essentially to describe a specialized database created specifically for content management systems. The acronym PHPCR actually stands for PHP content repository. But as mentioned before, the CMF is storage agnostic so its possible to combine the CMF with other storage mechanism, like Doctrine ORM, Propel etc.
This section will help you understand the basic parts of Symfony CMF Standard Edition (SE) and how they work together to provide the default pages you can see when browsing the Symfony CMF SE installation.
It assumes you have already installed Symfony CMF SE and have carefully read the Symfony2 book.
AcmeMainBundle and SimpleCmsBundle¶
Symfony CMF SE comes with a default AcmeMainBundle to help you get started, similar to the AcmeDemoBundle provided by Symfony2. This gives you some demo pages viewable in your browser.
There are several bundles working together in order to turn the fixture data into a browsable website. The overall, simplified process is:
- When a request is received, the Symfony CMF Routing's Dynamic Router is used to handle the incoming request;
- The Dynamic Router is able to match the requested URL to a
Pagedocument provided by SimpleCmsBundle and stored inside the database;
- The retrieved document information is used to determine which controller to pass it on to, and which template to use;
- As configured, the retrieved document is passed to
ContentControllerprovided by the ContentBundle, which render document into
layout.html.twigof the AcmeMainBundle.
Again, this is simplified view of a very simple CMS built on top of Symfony CMF. To fully understand all the possibilities of the CMF, continue reading this Book section.
If you want to review the contents of the PHPCR database you can use the following commands:
1 2 3
$ php app/console doctrine:phpcr:node:dump $ php app/console doctrine:phpcr:node:dump --props $ php app/console doctrine:phpcr:node:dump /path/to/node
The above examples respectively show a summary, a detailed view, and a summary of a node and all its children (instead of starting at the root node).
Don't forget to look at the
--help output for more possibilities:
$ php app/console doctrine:phpcr:node:dump --help
Adding new pages¶
Symfony CMF SE does not provide any admin tools to create new pages. If you
are interested in adding an admin UI have a look at
Creating a CMS using CMF and Sonata. However if all you want
is a simple way to add new pages that you can then edit via the inline
editing, then you can use the SimpleCmsBundle
page migrator. The Symfony
CMF SE ships with an example YAML file stored in
app/Resources/data/pages/test.yml. The contents of this file can be loaded
into the PHPCR database by calling:
$ php app/console doctrine:phpcr:migrator page --identifier=/cms/simple/test
Note that the above identifier is mapped to
app/Resources/data/pages/test.yml by stripping off the
configuration of the SimpleCmsBundle (which defaults to
Therefore if you want to define a child page
you would need to create a file
and then run the following command:
$ php app/console doctrine:phpcr:migrator page --identifier=/cms/simple/test/foo
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.