在Symfony中引用外部目录

时间:2013-09-01 14:33:44

标签: git symfony phpstorm directory-structure symfony-2.3

场合

我有一个 Base Symfony应用程序,可以与抽象类进行比较 我有多个客户 Symfony应用程序,所有这些都基于 Base 应用程序。
客户应用程序是简单的网站,每个网站都有不同的(只读)数据,主题等。

基础应用 - 作为独立功能

  • .htaccess文件,AppKernel,config.yml等
  • 多个供应商包
  • 基础捆绑包含一些基本视图
  • 缺少控制器
  • 缺乏路由
  • 缺乏客户特定资源

客户 - 包含 Base app

中缺少的元素
  • “注入” Base app
  • 控制器(S)
  • 路由
  • 客户特定资源(观点,css,js,数据等)

使用git,并且更愿意从 Base 代码创建一个git repo,每个 Customer repo引用 Base repo作为子模块。
这将 Base 代码保存在一个存储库中,并在 Customer repos之间保持清晰的分离。

root\ - (Customer repo)
    Customer\ - (Customer-specific files)
    Symfony\ - (Base app submodule repo)
       app\
       src\
          MyCompany\
             BaseBundle\
       vendor\
       web\

Sticking Point

无法让Symfony识别Customer\文件夹或其任何内容。

功能

  • Symfony 2.3
  • GIT中
  • Apache 2.4.4
  • PhpStorm
  • Windows 7 x64

尝试失败

  • 客户捆绑包添加到 AppKernel.php registerBundles
  • autoload.php中注册Customer\文件夹

1 个答案:

答案 0 :(得分:0)

使用外部Customer\目录作为MyCompany\目录中的源和目标,创建一个Junction符号链接。

在Symfony(子模块)repo的 .gitignore 中,添加customer/以忽略联结符号链接。

root\ - (Customer repo)
    Customer\ - (symlink source)
    Symfony\  - (git submodule)
       app\
       src\
          MyCompany\
             BaseBundle\
             Customer\ - (Junction symlink)
       vendor\
       web\

Complete Guide to Symbolic Links (symlinks) on Windows or Linux