Phing是一个PHP项目构建系统或建立一个基于工具的Apache Ant.
你可以做任何它,你可以做一个传统的构建系统,如GNU make工具,它的使用简单的XML构建文件和可扩展PHP的“任务”类使其易于使用和高度灵活的构建框架.
其特点包括运行PHPUnit的和SimpleTest的单元测试(包括测试结果和覆盖报告),文件转换(例如令牌替换,XSLT转换,Smarty的模板转换),文件系统操作,互动构建支持,SQL执行,CVS/SVN/GIT操作工具,用于创建PEAR包,文档生成(DocBlox,phpDocumentor)等
如果你发现自己编写自定义脚本来处理打包部署,或者您的应用程序的测试,那么我们建议在看Phing.Phing自带打包带大量即装即用的操作模块(任务),以及一个易于使用的面向对象模型来扩展或添加自己的自定义任务.
Phing提供以下功能
- 简单的XML构建文件
- 丰富提供任务
- 通过PHP类易于扩展
- 平台无关:工作在UNIX,Windows,Mac OSX版
- 无需外部依赖
- 专为PHP5
安装
安装Phing的首选方法是通过PEAR以及Phing PEAR通道。 你可以通过添加pear.phing.info通道到你的PEAR环境,然后安装Phing使用phing通道别名和phing包名安装Phing:
pear channel-discover pear.phing.info pear install [--alldeps] phing/phing
安装完成之后,为了调用方便可配置环境变量,使其可在命令行直接调用。
phing调用类似如下:
phing [target [target2 [target3] ...]]
通过xml格式配置,类似如下:
<?xml version="1.0" encoding="UTF-8"?>
<project name="FooBar" default="dist">
<!-- ============================================ -->
<!-- Target: prepare -->
<!-- ============================================ -->
<target name="prepare">
<echo msg="Making directory ./build" />
<mkdir dir="./build" />
</target>
<!-- ============================================ -->
<!-- Target: build -->
<!-- ============================================ -->
<target name="build" depends="prepare">
<echo msg="Copying files to build directory..." />
<echo msg="Copying ./about.php to ./build directory..." />
<copy file="./about.php" tofile="./build/about.php" />
<echo msg="Copying ./browsers.php to ./build directory..." />
<copy file="./browsers.php" tofile="./build/browsers.php" />
<echo msg="Copying ./contact.php to ./build directory..." />
<copy file="./contact.php" tofile="./build/contact.php" />
</target>
<!-- ============================================ -->
<!-- (DEFAULT) Target: dist -->
<!-- ============================================ -->
<target name="dist" depends="build">
<echo msg="Creating archive..." />
<tar destfile="./build/build.tar.gz" compression="gzip">
<fileset dir="./build">
<include name="*" />
</fileset>
</tar>
<echo msg="Files copied and compressed in build directory OK!" />
</target>
</project>
当然,phing也提供自定义的任务,可以自己用php来写任务.类似如下:
<br />
require_once "phing/Task.php";<br />
class MyEchoTask extends Task {<br />
/**<br />
* The message passed in the buildfile.<br />
*/<br />
private $message = null;<br />
/**<br />
* The setter for the attribute "message"<br />
*/<br />
public function setMessage($str) {<br />
$this->message = $str;<br />
}<br />
/**<br />
* The init method: Do init steps.<br />
*/<br />
public function init() {<br />
// nothing to do here<br />
}<br />
/**<br />
* The main entry point method.<br />
*/<br />
public function main() {<br />
print($this->message);<br />
}<br />
}<br />
写完后,可如下调用
<?xml version="1.0" ?>
<project name="test" basedir="." default="test.myecho">
<taskdef name="myecho" classname="phing.tasks.my.MyEchoTask" />
<target name="test.myecho">
<myecho message="Hello World" />
</target>
</project>
详细内容:可参见:http://www.phing.info/docs/stable/hlhtml/index.html#d5e811
ideas match tank top designs
cartoon porn Fashion Tips for Women Online
quick weight lossDesigner Sue Wong unveils her Fall 2013 Great Gatsby Collection
