简体   繁体   English

版本控制PHP Web项目

[英]Version control PHP Web Project

We have a PHP project that we would like to version control. 我们有一个我们想要版本控制的PHP项目。 Right now there are three of us working on a development version of the project which resides in an external folder to which all of our Eclipse IDEs are linked, and thus no version control. 现在,我们有三个人正在研究项目的开发版本,该版本驻留在我们所有Eclipse IDE都链接到的外部文件夹中,因此没有版本控制。

What is the right way and the best way to version control this? 什么是正确的方法和版本控制的最佳方式?

We have an SVN set up, but we just need to find a good way to check in and out that allows us to test on the development server. 我们有一个SVN设置,但我们只需要找到一个检查进出的好方法,这样我们就可以在开发服务器上进行测试。 Any ideas? 有任何想法吗?

We were in a similar situation, and here's what we ended up doing: 我们处于类似的情况,这就是我们最终做的事情:

  • Set up two branches -- the release and development branch. 设置两个分支 - 发布和开发分支。
  • For the development branch, include a post-commit hook that deploys the repository to the dev server, so you can test. 对于开发分支,包括一个后提交钩子,它将存储库部署到开发服务器,因此您可以进行测试。
  • Once you're ready, you merge your changes into the release branch. 准备好后,将更改合并到发布分支中。 I'd also suggest putting in a post-commit hook for deployment there. 我还建议在那里部署一个post-commit钩子。

You can also set up individual development servers for each of the team members, on their workstations. 您还可以在其工作站上为每个团队成员设置单独的开发服务器。 I find that it speeds things up a bit, although you do have some more setup time. 虽然你确实有更多的设置时间,但我发现它可以加快速度。

We had to use a single development server, because we were using a proprietary CMS and ran into licensing issues. 我们不得不使用单个开发服务器,因为我们使用的是专有CMS并遇到了许可问题。 So our post-commit hook was a simple FTP bot. 所以我们的post-commit钩子是一个简单的FTP机器人。

Here is what we do: 这是我们做的:

  • Each dev has a VM that is configured like our integration server 每个开发人员都有一个配置为我们的集成服务器的VM
  • The integration server has space for Trunk, each user, and a few slots for branches 集成服务器为Trunk,每个用户和分支的几个插槽提供空间
  • The production server 生产服务器
  • Hooks are in Subversion to e-mail when commits are made 提交时,挂钩在Subversion中发送电子邮件

At the beginning of a project, the user makes a branch and checks it out on their personal VM as well as grabs a clean copy of the database. 在项目开始时,用户创建一个分支并在其个人VM上检查它,并抓取数据库的干净副本。 They do their work, committing as they go. 他们做他们的工作,随着他们去做。

Once they have finished everything in their own personal space they log into the integration server and check out their branch, run their tests, etc. When all that passes their branch is merged into Trunk. 一旦他们完成了他们自己的个人空间中的所有内容,他们就会登录到集成服务器并检查他们的分支,运行他们的测试等等。当所有通过他们的分支的人都被合并到Trunk中。

Trunk is rebuilt, the full suite of tests are run, and if all is good it gets the big ol' stamp of approval, tagged in SVN, and promoted to Production at the end of the night. 重建Trunk,运行全套测试,如果一切顺利,它将获得批准的大标签,在SVN中标记,并在晚上升级到Production。

If at any point a commit by someone else is made, we get an e-mail and can merge those changes into our individual branches. 如果在任何时候由其他人提交,我们会收到一封电子邮件,并可以将这些更改合并到我们各自的分支机构中。

Beanstalk具有内置的提交后挂钩,用于部署到开发,登台和生产服务器。

What about something distributed? 分发的东西怎么样? You can start for example with Mercurial, try different workflows, and see which one fits you the best. 您可以从Mercurial开始,尝试不同的工作流程,并查看最适合您的工作流程。

One way to use subversion for PHP development is too setup a repository for one or all three developers, and use this repository, more as a syncing tool, than true version control. 将subversion用于PHP开发的一种方法是为一个或所有三个开发人员设置一个存储库,并使用此存储库作为同步工具,而不是真正的版本控制。

You could, 你可以,

  • Make a repo 回购

  • Add your entire PHP document structure of your project 添加项目的整个PHP文档结构

  • Checkout a copy of this repo into the correct spot on your dev server 将此repo的副本签出到dev服务器上的正确位置

  • Use an svn hook, that activates on commit 使用svn挂钩,在提交时激活

This hook, will automatically update the contents of the dev sever, whenever anybody on the team checks in any code. 只要团队中的任何人签入任何代码,此钩子就会自动更新开发服务器的内容。

Hook resides in: 胡克居住在:

svn_dir/repo_name/hooks/post-commit svn_dir / repo_name /挂钩/后提交

And could look like: 可能看起来像:

/usr/bin/svn up /path_to/webroot --username svn_user --password svn_pass / usr / bin / svn up / path_to / webroot --username svn_user --password svn_pass

That will update your working copy on the dev server to the latest check in. 这将在开发服务器上将您的工作副本更新为最新的签入。

您可以用于构建的另一个工具是TeamCity ,它可以免费提供20个构建配置(足以满足大多数小公司/项目。)这样您就可以运行测试以及计划构建。

你们每个人都可以在本地运行它,或者在你自己的开发服务器上运行它们(甚至是同一个具有不同端口的服务器......)。

One possible way (there are probably better ways): 一种可能的方式(可能有更好的方法):

Each of you should have your own checked out version of the project. 你们每个人都应该拥有自己的项目签出版本。

Have a local copy of the server on your computer and test it there throughout the day. 在您的计算机上拥有服务器的本地副本,并在那里进行全天测试。 Then at the end of each day (or whenever), you merge together whatever you are ready to test, and you check it out onto the dev server and test it. 然后在每天结束时(或每当),您将任何准备好测试的内容合并在一起,然后将其检出到开发服务器并进行测试。

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

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