2017 © Pedro Peláez
 

symfony-bundle symfony-multisite-bundle

This bundle allows you to manage multisite in symfony application.

image

prodigious/symfony-multisite-bundle

This bundle allows you to manage multisite in symfony application.

  • Thursday, July 26, 2018
  • by nan-guo
  • Repository
  • 0 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 400 % Grown

The README.md

Symfony Multisite Bundle

The repository contains the Symfony multisite bundle for Symfony 3. This bundle allows you to manage multisite in symfony application., (*1)

  • Each site can have its own database connection or use the same database.
  • Each site can have diffirent locales
  • Each site can have its own app folder and public folder
  • Each site can have its own robots.txt

Structure public folder

Each sites first looks for assets in its own folder, (*2)

For example (demo_2):, (*3)

The site demo_2 will first look for the image chat.png in, (*4)

/web/public/demo_2/imgs/chat.png, (*5)

if this image does not exist, the file /web/imgs/chat.png will be used, (*6)

Structure robots.txt

Each site can have its own robots.txt in the folder :, (*7)

/robots/hostname.txt, (*8)

if hostname.txt does not exist, the file /web/robots.txt will be used., (*9)

Installation


composer require prodigious/symfony-multisite-bundle

Setup

    $bundles = array(
        ...
        new Prodigious\MultisiteBundle\MultisiteBundle(),
        ...
    );

Then add these lines to your composer.json of your Symfony project:, (*10)

    "scripts": {
        "post-install-cmd": [
            ...
            "Prodigious\\MultisiteBundle\\Composer\\ScriptHandler::installBundle"
        ],
        "post-update-cmd": [
            ...
            "Prodigious\\MultisiteBundle\\Composer\\ScriptHandler::installBundle"
        ]
    }

Afterwards, initialize the bundle using, (*11)


composer install

After the installation, the bundle will create some files in your project :, (*12)

  • sites/
  • app/MultisiteKernel.php

And you need to modify some files :, (*13)

Add these lines to .htaccess in the folder web:
<IfModule mod_rewrite.c>
    RewriteEngine On

    # Multisite conditions
    RewriteCond %{DOCUMENT_ROOT}/robots/%{HTTP_HOST}.txt -f
    RewriteRule ^robots\.txt$ robots/%{HTTP_HOST}.txt [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^public/([^/]+)(?:/(.*)|$) /$2 [QSA,R,L]
    # End
</IfModule>
Modifiy your app.php and app_dev.php in the folder web:

Replace, (*14)

require __DIR__.'/../vendor/autoload.php

To, (*15)

require __DIR__.'/../sites/autoload/sites.php';

And Relace, (*16)

    // app.php
    $kernel = new AppKernel('prod', false);
    // app_dev.php
    $kernel = new AppKernel('dev', true);

To, (*17)

    // app.php
    $kernel = new MultisiteKernel('prod', false);
    $kernel->setSite($site);
    // app_dev.php
    $kernel = new MultisiteKernel('dev', true);
    $kernel->setSite($site);

Like this :, (*18)

// require __DIR__.'/../vendor/autoload.php';
require __DIR__.'/../sites/autoload/sites.php';

if (PHP_VERSION_ID < 70000) {
    include_once __DIR__.'/../var/bootstrap.php.cache';
}

$kernel = new MultisiteKernel('prod', false);
$kernel->setSite($site);
if (PHP_VERSION_ID < 70000) {
    $kernel->loadClassCache();
}

Instructions

There is a list of commands to manage your sites., (*19)

Create a new site


php bin/console site:create

screenshot, (*20)

Get the list of sites


php bin/console site:list

screenshot, (*21)

Disable a site


php bin/console site:disable --name=demo_1

screenshot, (*22)

Enable a site


php bin/console site:enable --name=demo_1

screenshot, (*23)

Delete a site


php bin/console site:delete --name=demo_1

screenshot, (*24)

Synchronizer configuration


php bin/console site:config:sync

Attributes


$currentSite = $request->attributes->get('site'); // 'app' by default

$currentInstance = $request->attributes->get('instance');

$currentLocal = $request->getLocale();

Additional info

Author: Nan GUO, (*25)

Company : Prodigious, (*26)

The Versions

26/07 2018

dev-master

9999999-dev https://github.com/nan-guo/Symfony-Multisite-Bundle.git

This bundle allows you to manage multisite in symfony application.

  Sources   Download

MIT

The Requires

 

symfony multisite symfony multi-sites multisite bundle multi-sites bundle

26/07 2018

1.0.3

1.0.3.0 https://github.com/nan-guo/Symfony-Multisite-Bundle.git

This bundle allows you to manage multisite in symfony application.

  Sources   Download

MIT

The Requires

 

symfony multisite symfony multi-sites multisite bundle multi-sites bundle

21/05 2018

1.0.2

1.0.2.0 https://github.com/nan-guo/Multisite-Bundle

This bundle allows you to manage multisite in symfony application.

  Sources   Download

MIT

The Requires

 

symfony multisite symfony multi-sites multisite bundle multi-sites bundle

18/05 2018

1.0.0

1.0.0.0 https://github.com/nan-guo/Multisite-Bundle

This bundle allows you to manage multisite in symfony application.

  Sources   Download

MIT

The Requires

 

symfony multisite symfony multi-sites multisite bundle multi-sites bundle