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 tiggerramdisk为什么会引导超时
  • ¥15 python随机森林对两个excel表格读取,shap报错
  • ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
  • ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。
  • ¥30 求给定范围的全体素数p的(p-2)/p的连乘积值
  • ¥15 VFP如何使用阿里TTS实现文字转语音?
  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument