Version

Documentation » Page

5. Error Pages »

« 3. Getting Started

4. Multisite

The PageBundle handles multisite out of the box. However due to some limitation of the Symfony2 API, the multisite support is done around 2 strategies :

  • host : you can configure a site per host. This strategy works out of the box

    with no changes.

  • host with path : you can configure site per host and per path. This strategy

    requires some changes.

4.1. Host Strategy

With this strategy it is possible to handle sites like :

Just configure the sonata_page section as:

sonata_page:
    multisite: host
    [...]

And that’s it!

4.2. Host and Path Strategy

With this strategy it is possible to handle sites like :

This strategy required a dedicated Request object. So you need to alter the front controller to use the one provided by the PageBundle. To to so, open files: app.php and app_dev.php and change the use statement to

use Sonata\PageBundle\Request\SiteRequest as Request;

Working file example :

<?php
require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();

use Sonata\PageBundle\Request\SiteRequest as Request;

$kernel->handle(Request::createFromGlobals())->send();

The last action is to configure the sonata_page section as:

sonata_page:
    multisite: host_with_path
    [...]

And that’s it!

Note

If you have a working site with the PageBundle, you just need to create a Site and update the page table and the snapshot table with the correct Site id value.

Found a typo? Something is wrong in this documentation? Just fork and edit it!