1

I'm developing a modular propietary PHP application. As a project leader and owner, I want to keep the core engine confidential. The freelancers will work on modules (say 1 freelancer for 1 module where they can't see other's module).

I created repos for core (1 repo) and modules (1 repo for 1 module). AFAIK the repo should be placed outside htdocs. Now I think about this scenario: Using SVN, I'll give access to repo A for freelancer A, repo B for freelancer B, etc. When A checkout, he'll only have module A on his computer to edit. To test his module, he'll commit. But as it goes to svn dir instead of htdocs, he won't be able to test it instantly. He'll then need to export the commited code to htdocs. Well, I want to skip this export step.

(1) Is there a way he can commit his code to htdocs directly to test it to make it more practical?

(2) Is there any better scenario to achieve this (i.e. freelancer only allowed to read/write the module he worked on, and have no access - even read - to other module and core system)?

4

1 回答 1

1

你说的三个地方:

  • Subversion 存储库本身。这是所有源代码所在的位置。可以通过与服务器对话的 Subversion 客户端访问存储库。服务器可以使用SVN协议或HTTP/HTTPS。如果你想使用HTTP/HTTPS,你需要设置一个 Apache 服务器。如果要运行SVN,则需要svnserve运行该进程。
  • 开发者系统上的本地工作目录。这是文件被签出的地方,也是开发人员可以进行更改的地方。它不一定与存储库在同一台机器上。
  • PHP 网络服务器。这是 PHP 文件需要在其中才能工作并可能进行测试的地方。

让我们一次看一个:使用SVNHTTP/HTTPS,可以限制谁可以查看、签出并将代码提交到存储库中。在 Subversion 中,您可以将其指定为目录级别。因此,一个开发人员可以签入代码,http://myserver/svnrepos/module1而另一个开发人员可以签入和签出来自 的代码http://myserver/svnrepos/module2,并且他们都无法在http://myserver/svnrepos/core

棘手的部分是将这些信息放到服务器上进行测试。问题是如何允许开发人员在不必将代码放到服务器上的情况下进行提交。有几种方法可以做到这一点。

一种是创建服务器分支。如果开发人员想要 PHP 服务器上的代码,他们会将代码合并到服务器分支上。然后,您需要一种将代码从存储库移动到 PHP 服务器的机制。

我不会为此目的使用提交后挂钩。您不希望开发人员等待挂钩将他们的代码复制到服务器。此外,您可能希望启动和关闭服务器。

相反,使用 crontab 来监视 Subversion 存储库(尤其是服务器分支),然后当它检测到更改时,关闭服务器,更新服务器中的文件,然后重新启动服务器。我的方法是使用两个不同的目录。在服务器上有 directory1。用于svn export将文件导出到目录 2。因此,服务器仍然处于启动状态。然后,关闭服务器,移动directory2directory1,然后重新启动服务器。这样可以将停机时间降至最低,并使服务器处于或多或少的稳定状态。

但是,您应该查看Jenkins以帮助您完成项目。Jenkins 将允许您和您的开发人员查看他们的更改(您可以限制谁看到什么),进行基本测试。例如,您可以在提交后运行PHPMD(查看代码有多混乱)和CPD(复制粘贴检测器),Jenkins 将显示结果。然后,您可以在 Jenkins 上放置一个部署按钮,开发人员可以将他们的构建部署到服务器。

Jenkins 易于设置和使用。有大量用于各种缺陷跟踪系统、Subversion 和各种测试模块的插件。我不知道PHP有多少可用,但你可以看看。

于 2011-09-25T03:33:07.793 回答