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 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试