prodigious/symfony-multisite-bundle
Composer 安装命令:
composer require prodigious/symfony-multisite-bundle
包简介
This bundle allows you to manage multisite in symfony application.
README 文档
README
The repository contains the Symfony multisite bundle for Symfony 3. This bundle allows you to manage multisite in symfony application.
- 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
For example (demo_2):
The site demo_2 will first look for the image chat.png in
/web/public/demo_2/imgs/chat.png
if this image does not exist, the file /web/imgs/chat.png will be used
Structure robots.txt
Each site can have its own robots.txt in the folder :
/robots/hostname.txt
if hostname.txt does not exist, the file /web/robots.txt will be used.
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:
"scripts": {
"post-install-cmd": [
...
"Prodigious\\MultisiteBundle\\Composer\\ScriptHandler::installBundle"
],
"post-update-cmd": [
...
"Prodigious\\MultisiteBundle\\Composer\\ScriptHandler::installBundle"
]
}
Afterwards, initialize the bundle using
composer install
After the installation, the bundle will create some files in your project :
- sites/
- app/MultisiteKernel.php
And you need to modify some files :
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
require __DIR__.'/../vendor/autoload.php
To
require __DIR__.'/../sites/autoload/sites.php';
And Relace
// app.php
$kernel = new AppKernel('prod', false);
// app_dev.php
$kernel = new AppKernel('dev', true);
To
// app.php
$kernel = new MultisiteKernel('prod', false);
$kernel->setSite($site);
// app_dev.php
$kernel = new MultisiteKernel('dev', true);
$kernel->setSite($site);
Like this :
// 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.
Create a new site
php bin/console site:create
Get the list of sites
php bin/console site:list
Disable a site
php bin/console site:disable --name=demo_1
Enable a site
php bin/console site:enable --name=demo_1
Delete a site
php bin/console site:delete --name=demo_1
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
Company : Prodigious
prodigious/symfony-multisite-bundle 适用场景与选型建议
prodigious/symfony-multisite-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 503 次下载、GitHub Stars 达 5, 最近一次更新时间为 2018 年 05 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony multisite」 「symfony multi-sites」 「multisite bundle」 「multi-sites bundle」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 prodigious/symfony-multisite-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 prodigious/symfony-multisite-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 prodigious/symfony-multisite-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easily switch between sites on any page of your website.
The bundle for easy using json-rpc api on your project
Bundle Symfony DaplosBundle
Run wp-cron on all public sites in a multisite network
Search a SilverStripe site with Fluent options
Implements network-wide user roles in WordPress.
统计信息
- 总下载量: 503
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-05-18




