承接 alexandresalome/multisite-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alexandresalome/multisite-bundle

最新稳定版本:v0.2.0

Composer 安装命令:

composer require alexandresalome/multisite-bundle

包简介

A bundle to manage multiple sites with different brandings and locales

README 文档

README

Build status Latest Stable Version Total Downloads License Monthly Downloads Daily Downloads

This bundle allows you to manage multiple brandings and multiple locales in a Symfony2 application.

Requirements:

  • FrameworkExtraBundle
  • TwigBundle

Features

  • Multiple routes for each site
  • Configuration per site
  • Templates per site

Installation

Add to your composer.json:

{
    "require": {
        "alexandresalome/multisite-bundle": "~0.1"
    }
}

Add the bundle to your kernel:

# app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            # ...
            new Alex\MultisiteBundle\AlexMultisiteBundle(),
        );
    }
}

Configuration

Add this section to your config.yml file:

alex_multisite:
    default_branding: branding_A
    default_locale:   fr_FR
    brandings:
        _defaults:
            register: true
        branding_A:
            en_GB: { host: branding-a.com }
            fr_FR: { host: branding-a.com, prefix: /fr }
        branding_B:
            _defaults:
                register: false
            en_GB: { host: branding-b.com }
            de_DE: { host: branding-b.de, register: false }

In this section, you must configure your brandings and locales.

You can also add extra options, like the register option here.

Declare your routes

In your controllers, substitute

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

with

use Alex\MultisiteBundle\Annotation\Route;

You can then configure a multisite route in two ways:

/**
 * @Route(name="login", paths={
 *   "fr_FR"="/connexion",
 *   "en_GB"="/login"
 * })
 */
public function loginAction()
# ...

The path will be the same for all brandings, but will be localized. If you want a different path for same locale in different sites:

/**
 * @Route(name="login", paths={
 *   "branding_A"={
 *     "fr_FR"="/connexion-on-A",
 *     "en_GB"="/login-on-A",
 *   },
 *   "branding_B"={
 *     "en_GB"="/login-on-B",
 *   },
 * })
 */
public function loginAction()
# ...

Override templates

If you want to change a template for a specific site, create a similarly named file with branding/locale option in it:

Given your default template is AcmeDemoBundle::contact.html.twig.

You can override it with branding, locale, or both:

  • AcmeDemoBundle::_branding_locale/contact.html.twig
  • AcmeDemoBundle::_branding_/contact.html.twig
  • AcmeDemoBundle::__locale/contact.html.twig

Just create the file and it will automatically be loaded in place of the previous one.

Read the site context

From templates, use the global variable site_context, which returns a Alex\MultisiteBundle\Branding\SiteContext instance:

You are currently on {{ site_context.currentBrandingName }}
Your locale is {{ site_context.currentLocale }}

You can also read options from config with:

The option register is {{ site_context.option('register') ? 'enabled': 'not enabled' }}

In your controllers, use service site_context:

public function indexAction()
{
    $this->get('site_context')->getCurrentLocale();
    $this->get('site_context')->getOption('register');
}

Disable route sorting

You might want to rely on natural order of routes. If you're in this case, you can disable the optimization by providing the sort_route option:

alex_multisite:
    sort_routes: false
    # ...

Security

You can combine this bundle with Symfony's SecurityBundle, and use this bundle for your routes for login form page.

But, you must not use the multisite feature for the following routes:

  • login-check
  • logout

alexandresalome/multisite-bundle 适用场景与选型建议

alexandresalome/multisite-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37.57k 次下载、GitHub Stars 达 66, 最近一次更新时间为 2014 年 04 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 alexandresalome/multisite-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 alexandresalome/multisite-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 alexandresalome/multisite-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 37.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 66
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 66
  • Watchers: 6
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-12