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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵