使用composer
Following Alexander Cogneau’s introduction to dependency management with Composer, you now know that Composer is a resolver for managing external project dependencies and versioning constraints. But is that all it does? In this article I’ll show you how Composer can also be used as a basic build automation tool.
在Alexander Cogneau介绍了Composer的依赖关系管理之后 ,您现在知道Composer是用于管理外部项目依赖关系和版本约束的解析器。 但这就是全部吗? 在本文中,我将向您展示Composer如何也可以用作基本的构建自动化工具。
作曲家脚本 (Composer Scripts)
Any build automation tool worth its salt must provide the ability to script a range of automated tasks – from building, packaging, and running test suites, to deployment on staging and production systems. Phing, for example, is based on Ant and permits you to define such tasks in XML build files.
任何值得一试的构建自动化工具都必须具备编写一系列自动化任务的能力,这些任务从构建,打包和运行测试套件到在登台和生产系统上进行部署。 例如,Phing基于Ant,并允许您在XML构建文件中定义此类任务。
Composer differs in this regard in that it makes no assumptions as to what these tasks are, or if they are to be performed at all. What Composer does instead is expose its pre- and post- install/update/uninstall event hooks during execution which you can callback using “scripts”, much the same way that Pyrus provides the ability to define custom commands in the package.xml
via the --plugin
option to its install
, upgrade
, and uninstall
commands.
Composer在这方面的不同之处在于,它不对这些任务是什么或是否要执行这些任务做出任何假设。 相反,Composer所做的是在执行期间公开其安装前和安装后/更新/卸载事件挂钩,您可以使用“脚本”进行回调,这与Pyrus通过以下方式