doubo4336 2015-05-14 06:40
浏览 41
已采纳

有作曲家的多个应用程序

There is a main application, let's call it APP.

APP has several dependencies (including open source projects and proprietary libraries).

There are multiple clients that use their own instance of APP (on different domains that I manage). Some of these clients use a slightly adjusted version of APP. I implemented this by creating a specific module (let's call it SM) for each client that I just add to their instance of APP (so that I don't change any of the code from APP).

Currently, I've implemented this as follows:

  • Develop APP locally, use Composer to update its dependencies (composer update), push APP on central repo

  • For each regular client, pull APP from central repo and install the Composer dependencies (composer install)

  • For clients with specific implementation, create a new SM (specific module), that has the following composer.json file:

    ...
    "require": {
        "APP": "X.X.X"
    } 
    ...
    

Then apply the same steps as before for this SM (composer update locally, PUSH to central repo, PULL from central repo, composer install).

Everything is fine, except for two issues that I'd like to overcome:

  1. composer.lock from APP will be ignored by SM (since APP is loaded as a library in the vendor/ folder, and composer ignores the composer.lock files of libraries); this is not good at all, as I will not be confident that the specific clients will use the exact same libraries as APP.

  2. Each time I fix a bug or implement a new feature in APP (and this happens frequently - a few times a day), apart from the steps that I perform for the regular clients, I also need to rebuild the SMs (since one of their libraries - APP - was updated to a new version that I need to use). This is an overhead since most of the changes that I perform are inside APP (and not SM). So, if it was the other way (APP having SM as a dependency), it would have been working faster (since I wouldn't need to composer update on each SM).

Are there any known workflows or best practices that cover this scenario in order to mitigate the two issues above or at least to decrease the complexity of the upgrade/deployment process?

Please note that most of the steps above are already automated, so my question is not about the automation part, but the complexity of this architecture

  • 写回答

1条回答 默认 最新

  • duangangpin078794 2015-05-14 18:05
    关注

    I implemented this by creating a specific module (let's call it SM) for each client that I just add to their instance of APP

    For clients with specific implementation, create a new SM (specific module), that has the following composer.json file:

    It's an application with a client specific module (next to other dependencies).

    The application has the module as dependency (APP having SM as a dependency).

    And not: the module pulls the application as it's vendor dependency in. This will only cause extra steps to take during the development phase (your issue 2).

    I would suggest to refactor the application and it's modules until you get the following folder structure:

    |-application             #< the application has dependencies
      |-src
      |-tests
      |-vendor
        |-framework           #< maybe your application is framework based
        |-libs                #< more dependencies
        |-...                 #< other modules
        |-sm                  #< the client specific module
    

    This allows to pull in dependencies, which extend "the application" for client-specific needs.

    This overcomes your issue 1, because APP is the main repository and contains the lock file. It's essential to lock the versions, so that all developers are bound to the same versions and also for packaging exactly the same set of versions.

    So, if it was the other way (APP having SM as a dependency), it would have been working faster (since I wouldn't need to composer update on each SM).

    Yes! The need to rebuild the module, each time you change APP would vanish, if you start to "develop inside APP" with module dependencies.


    And for multiple clients, simply use multiple application repos, which have a custom set of requirements. 10 clients, 10 application repos, 10 composer.json files. Run composer install no-dev then pre-package each repo and place zip into downloads. Done.

    You can use a "container" or "packaging" project here, where the composer.json of each project would include the app and the specific modules. You might utilize the caret or tilde operator to specify a version range for the app ("vendor/app": "^1.2.3") and then simply update and repackage, after a new version of the application is released. This approach should work with the composer autoloading, because the application will remain inside the vendor folder, too. Only a little wrapper is needed, to set the composer autoloader up and switch over to your application.

    Or, if the application is really modular. Just package the main application and provide the client-specific modules as extra downloads. With this approach upgrades will have multiple download steps: upgrade app, upgrade modules. Think of it as "wordpress-style" updates/upgrades.


    You might reduce the complexity of the upgrade/deployment process further by dropping the composer install --no-dev part on the client machine by building "client-specific application archives" on the developer machine. These are basically the "--no-dev" package of the application with all it's dependencies, including the client-specific module(s) = pre-packaged.

    Like, Application-v1.2.3-WithModuleAForClientA-v3.2.1.zip.

    On the dev machine: composer install --no-dev --optimize-autoloader + zip.

    To install or upgrade simply download to the client, extract, execute the upgrade script. Done.

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

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大