PHP 构建/集成工具:您使用它们吗?
阅读 2008 年 11 月版 php|architect 杂志 中的“现代 PHP 工作流程”文章后, 讨论了单元测试 (phpUnit)、构建工具 (Phing)和持续集成 (Xinc) ,我受到启发,进一步了解了一些可用于 PHP 的工具,尤其是 Phing。
过去,我经常通过将实时站点作为 subversion 工作副本运行并简单地在生产机器上运行“svn update”来部署最新版本的代码来处理到生产服务器的部署。
您使用 PHP 代码构建工具吗? 您认为与直接从 subversion 进行部署相比,它们具有哪些优势? 我应该注意什么,或者我可能会遇到什么问题?
After reading the "Modern PHP workflow" article in the November 2008 edition of php|architect magazine which
discussed unit testing (phpUnit), build tools (Phing) and continuous integration (Xinc), I'm inspired the learn more about some of the tooling available for PHP, especially Phing.
In the past I've often handled deployment to a production server by running the live site as a subversion working copy and simply running an "svn update" on the production box to deploy the latest version of the code.
Do you use build tools for PHP code? What advantages you you believe they offer over deploying direct from subversion? What should I look out for, or what gotchas might I face?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我用过 Phing 和 Ant,更喜欢后者。 我最初选择 Phing 是因为它是用 PHP 编写的,但说实话它不像 Ant 那么成熟。 最后,拥有一个成熟的构建系统和一个大型社区更有价值。
使用 Ant/Phing 完成的事情:
I have used both Phing and Ant and prefer the latter much more. I initially went with Phing due to it being written in PHP but to be honest it isn't as mature as Ant. In the end, having a mature buildsystem with a large community is worth more.
Things done with Ant/Phing:
我发现 Phing 的一个大问题是它创建了一个不必要的间接层。 PHP是一种脚本语言,因此可以直接运行。 Phing 对 XML 配置的使用不太适合该语言:它确实提供了更具可读性的声明性配置,但代价是牺牲了该语言的任何灵活性。 对于 Ant(这条路线的灵感来源)来说这是有道理的,因为 Java 不具备这种灵活性,因为它的动态性较差并且需要编译。
不幸的是,我在 PHP 领域还没有看到很多好的替代方案,并且与其他语言不同,构建工具不是那么重要,也不是文化的一部分,因此另一个得到良好支持的选项的发展可能不会很快发生。
因此,我会坚持选择更接近 PHP 可以从更积极支持构建工具的文化中实现的功能。 我通常使用 Gradle。 Rake 也能做得很好,具体取决于你想用哪种语言作弊(可能还有其他类似的选项) )。 如果您喜欢 Webdriver 支持,您还应该权衡此类事情。 否则,使用 PHP 和/或 BASH 创建轻量级解决方案应该涵盖所有内容,同时保持透明度
A large issue that I see with Phing is that it creates a needless layer of indirection. PHP is a scripting language, and therefore could be run directly. Phing's use of XML configuration is a poor fit for the language: it does provide a more readable declarative configuration, but at the cost of sacrificing any of the flexibility of the language. With Ant (the inspiration for that route) it makes sense since Java did not have that flexibility as it is less dynamic and requires compilation.
Unfortunately I haven't seen many good alternatives in the PHP space, and unlike other languages build tools are not as essential or a part of the culture so the evolution of another well supported option may not happen any time soon.
I'd therefore stick to options that are closer to what PHP could do from cultures that more aggressively support build tools. I normally use Gradle. Rake also does a great job depending on with which language you want to cheat (and there may be other similar options). You should also weigh things like Webdriver support if you're into that type of thing. Otherwise creating a lightweight solution using PHP and/or BASH should cover everything while maintaining transparency
我看了看Phing,它看起来很棒。 对于我正在从事的项目,我实际上使用的是 Apache 的 Ant。 我用它来做几件事:
我认为 Phing 比 Ant 更值得关注因为它是本机 PHP,这可能很好。此外,如果您所做的不仅仅是复制/移动文件,那么当您转移到生产环境时,我遇到了 YUI 压缩器在本地运行良好的问题。机器,但在相对较小的 VPS 上速度超级慢。
I looked at at Phing at it looks pretty awesome. For the project I'm working on I'm actually using Apache's Ant. I use it to do a several things:
I think Phing is worth looking at over Ant because it's native PHP, which could be nice. Also if you are doing anything more than just copy/moving files around look out for performance issues when you move to the production environment. I had an issue where the YUI compressor ran fine on my local machine but on the relatively small VPS it was super slow.
在我现在正在进行的一个项目中,我们使用 phpUnderControl 来运行测试并在以下情况下获得快速反馈:有东西坏了。 我们计划使用它来运行其他测试,例如用 Watir 编写的一些测试。
On a project I'm working on now we're using phpUnderControl to run tests and get fast feedback when something's broken. We plan to use it to run other tests as well such as some written in Watir.