dougou8552 2018-10-24 08:26
浏览 78
已采纳

如何使用git与MVC模式

How to use git, when I have large tree of folders in file structure of web-project. Module, which I developing is separated by different folders in this file structure. As it is customary by MVC pattern concern.

In the overall file structure of web-project I have, roughly speaking:

  • model folder
  • controller folder
  • views folder
  • languages folder
  • and so on

I making changes in files at this folders and need track changes. These folders are not combined in one folder, that associated with module, that I developing. These folders are scattered in different parts of the file structure.

I could create git repository at the root of file structure and in .gitignore specify, which folders track. But I develop many modules. And I need separate git repositories for them.

Where and how create git repositories to developing many modules in large file structure?

If I init git repository at the root of web-project is it possible to create many repositories at the root of file structure for each module and for each repository specify which folders git should track?

  • 写回答

1条回答 默认 最新

  • dongpan3001 2018-10-24 08:55
    关注

    I think simplest solution now days it's to keep your independent modules in separated repositories and then requesting them using composer.

    I will show you some theoretical example of it.

    I have project, which should use Payment Module. Payment Module is a separated repository with composer.json file provided in root directory.

    For example:

    {
      "name": "company/payment-module",
      "description": "Module handling payments from our customers.",
      "autoload": {
        "psr-4": {
          "Company\\PaymentModule\\": "src/"
        }
      }
    }
    

    That gives you possibility of using any of modules created in any application/project you'll build. So, for example in your project you can require Payment Module as dependency.

    {
      "name": "company/shop",
      "type": "project",
      "description": "The main repository of our shop.",
      "autoload": {
        "psr-4": {
          "": "src/"
        }
      },
      "repositories": [
        {
          "type": "git",
          "url": "https://github.com/company/payment-module"
        }
      ],
      "require": {
        "company/payment-module": "dev-master"
      }
    }
    

    When you define modules you want in the project and install them using composer, they will be under vendor/ directory and will be autoloaded into the namespaces you define.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 lvgl V9移植到linux开发板
  • ¥15 VB.net中在窗体中创建一个button控件来关闭窗体,但是提示错误,我该怎么办
  • ¥15 网上下载好的程序但是arduinoIDE编程报错,运行不了,哪里出错了,能具体给改一下吗
  • ¥15 Sharepoint JS开发 付费技术指导
  • ¥15 输入程序运行仿真后,烟雾值不实时检测,变成固定值
  • ¥20 数据排序,可选择排序方向
  • ¥15 修改一下代码,考虑进程到达时间不同的情况
  • ¥15 帮我看看这是个啥题,带解题过程和结果,条件如下FCF = 290471.33 g1 = 15% r = 8% g2 = 4% n = 5
  • ¥15 edem模拟颗粒不显示或者生成失败
  • ¥15 Python代码编写