承接 senj/dynamic-subdomain-bundle 相关项目开发

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

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

senj/dynamic-subdomain-bundle

Composer 安装命令:

composer require senj/dynamic-subdomain-bundle

包简介

Symfony3 Dynamic subdomain handler Bundle

README 文档

README

Install

In composer.json:

"require": {
    "senj/dynamic-subdomain-bundle": "dev-master"
}

In app/AppKernel.php:

$bundles = array(
    # [...]
    new Senj\DynamicSubdomainBundle\SenjDynamicSubdomainBundle(),
    # [...]
);

Configure

In app/config.yaml

senj_dynamic_subdomain:
    base_host: domain.com
    parameter_name: ~
    entity: Acme\DemoBundle\Entity\MySite
    property: ~
  • base_host:

    • The domain base host, where all subdomains are attached
    • required
    • example: domain.com
  • parameter_name:

    • The name of the parameter that will be set on the current Request
    • optional
    • default value: subdomain
  • entity:

    • The class or Doctrine alias of the entity mapped to subdomains
    • required
    • example: Acme\DemoBundle\Entity\MySite
  • property:

    • The name of the property storing the subdomain name in your entity
    • optional
    • default value: subdomain
  • method:

    • The name of method that will be called to get object with the property defined
    • optional
    • default value: findOneBy

Use

  1. Create the entities mapped to your subdomains
  2. Get the current subdomain object through the Symfony Request object

In php, assuming that senj_dynamic_subdomain.property equals subdomain (the default value):

use Symfony\Component\HttpFoundation\Request;

class DefaultController extends Controller {

    public function indexAction(Request $request) {
        $subdomainobject = $request->attributes->get('subdomain');
        var_dump($subdomainobject);
    }

In twig, assuming that senj_dynamic_subdomain.property equals subdomain (the default value), and that the entity mapped to subdomains has a title property:

{{ app.request.attributes.get('subdomain').title }}

Notes

If the subdomain is not found in the database, an exception will be thrown by the Bundle (Symfony\Component\HttpKernel\Exception\NotFoundHttpException).

统计信息

  • 总下载量: 97
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固