简体   繁体   English

将代码分布到多个位置

[英]Distributing code to multiple locations

bit of a theory questions leading to possibly a bit more practical. 一些理论问题可能导致更实际一些。 I currently have a web application developed using PHP within a codeigniter framework. 我目前有一个Web应用程序是在codeigniter框架中使用PHP开发的。

The application is now in use by 5 separate customers each with their own specific amendments that extend the base/core code I have created. 该应用程序现在由5个单独的客户使用,每个客户都有自己的特定修订,这些修订扩展了我创建的基本/核心代码。 I'm now at the time that whenever I make any updates to the development version I am having to painstakingly hand copy each of the separate files/directories to each customer. 我现在的时间是,每当对开发版本进行任何更新时,我都必须努力将每个单独的文件/目录复制到每个客户。

I'd like a bit input on how best to automate this process. 我想对如何最好地自动化此过程提供一些意见。 The scenario is that the applications are running on a windows server with php 5.4 connecting to a mysql database. 该方案是应用程序在Windows Server上运行,并且php 5.4连接到mysql数据库。 All domains/applications including the dev version are on the same server and use the same IP Address. 所有域/应用程序(包括开发版本)都位于同一服务器上,并使用相同的IP地址。

Would I be correct in thinking a batch file would be the best way to do this, if so can someone point me in the right direction for creating a batch file. 我认为批处理文件将是执行此操作的最佳方法是否正确,如果有人可以为我指出创建批处理文件的正确方向。 Other thoughts I've had are possibly a download button on each site that starts the process of updating itself but again i'm not entirely sure how to go about this. 我的其他想法可能是每个站点上的下载按钮,该按钮开始更新自身,但是我也不完全确定该怎么做。

Any input is greatly appreciated. 任何输入,不胜感激。

Thanks 谢谢

It really depends on how extensive your modifications are for the individual clients. 这实际上取决于您对单个客户所做的修改有多广泛。 Is 90% shared code? 90%是共享代码吗? 50%? 50%?

If 90% of the code is common code: I would put my core codebase in one folder and then just use custom files for the modifications. 如果90%的代码是通用代码:我会将核心代码库放在一个文件夹中,然后仅使用自定义文件进行修改。

In the core code you need a way to tell the clients apart. 在核心代码中,您需要一种区分客户的方法。 Let's assume you have a 'clientid' that is unique to the client. 假设您有一个客户端唯一的“ clientid”。

Example: Let's say we are in the core code and going to include a file called user_admin.php but this file is different for some of your clients but not all 示例:假设我们在核心代码中,并将包含一个名为user_admin.php的文件,但是对于您的某些客户端,此文件有所不同,但并非全部

function custominclude($file,$clientid){
    $customfile='/custom/'.$clientid.'/'.$file;
    if(file_exists($customfile)){
        include ($customfile); 
    }
    else{
        include ($file); 
    }
}
custominclude('user_admin.php',$clientid);

EDIT based on your comment below. 根据下面的评论进行编辑。

To sync two folders (or more) on a windows server. 在Windows服务器上同步两个(或多个)文件夹。 Use a utility like GoodSync http://www.goodsync.com/ . 使用类似GoodSync的实用程序http://www.goodsync.com/ It lets you sync folders one way/both ways on the same machine or between different ones. 它使您可以在同一台计算机上或在不同计算机之间以一种方式/两种方式同步文件夹。 It should handle your task easily. 它应该可以轻松地处理您的任务。 You can set it up to do it on a schedule or you can manually tell it you sync when you want. 您可以将其设置为按计划执行,也可以手动告诉它在需要时进行同步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM