PHING User Guide
What is paing?
PHING is a project code building system based on Apache Ant. You can use her to do anything you can do, such as gnu make, and phing uses simple XML build files and scalable "tasks" to make it easy Use and the extensible frame.
Because phing is Ant based, some of this manual is taken from the ANT manual.
PHING & BINARYCLOUD: History
PHING is a child project from binarycloud. BinaryClound is a highly engineered framework for use in an enterprise environment. BinaryCloud uses XML to store metadata (configuration, nodes, widgets, site structure,). and many more).
Because binarycloud is built for PHP, XML processing and conversions are performed on each page request is unrealistic .phing is used to "compile" XML metadata is an array form that can be processed by the PHP engine.
Of course, XML "Compilation" is just binarycloud using a .phing build system in many ways to build a system, allow you to:
1. Build a multilingual page from a single source tree.
2. Gathering metadata (metadata) in a single XML file and generates several files with multiple different XSLTs. (Translator Note: In the XSLT2.0 specification, eliminate 1.0 specification can only have a limit to enter an output Now we can do a single input to generate multiple output files)
Initially, BinaryCloud uses the GNU Make build system, but this is some shortcomings. "Space Before Tab Problem" in makefile. In fact, it is only available on UNIX systems. So you need to find a better architecture .apache Ant is a good choice - it uses XML to build files and modular design. But the problem is written with Java, you must use it you must install Java virtual machines on your computer.
Besides the need for yet another interpreter (i.e. besides PHP), there was also legal / ideological conflict in requiring a commercial JVM (there were problems with Ant on JVMs other than Sun's) for an LGPL'd Binarycloud.
Therefore, PHING began to develop, and paing is a build system written with PHP with Ant. The first version is designed and developed, so it is not very stable. The system quickly exposed its restrictions and needs a better PHING system. Therefore, the prototype of pHING2 is derived.
PHING current development focuses on pHING2, which involves many functions, bug corrections, and most worthless transformations are based on PHP5 abstract classes, interfaces, and try / catch / throw exceptions to override the original pHING base code.
How to work
PHING uses the XML build file that contains a set of items. Build a file consisting of some targets that run the actual command (such as copying files, deleting directories, executing database queries, etc.). So use phing, first step by writing Build File, then run the pHING, to build the target to be executed in the built file.
PHING -F mybuildfile.xml mytarget
As shown in Figure 1. Type a description of the command parameters
By default, Phing will find a file called Build.xml. (Unless the name of the building is not build.xml, you don't have to specify the name of the build file for the pHING) and if you do not specify any target, then phing will be executed in < The default target set in the Project> tag (specified by the default property).
COOL, SO How Can I Help?
PHING is currently actually developing and many things to be completed. If you want to participate, you can pass the following method:
1. Read this manual to hing ;-)
2. Go to http://phing.tigris.org Subscribe to the "dev" mailing list
Setting with phing
The goal of this chapter is to help you set up and execute on your operating system. Once you have correctly setup, you don't have to go back and see this chapter, unless you have to reinstall, or migrate to other Platform. There are several ways to get a pHING issuance package. If you don't want to participate in the current development, it is recommended that you get the nearest snapshot version or stable version. If you are interested in participating in my development, you can get developed from CVS Document.
The easiest way to get the PHING distribution package is to access the home page http://phing.info Download the current format of the distribution package.
from
After version 2.0.0B1, you can download PEAR installation packages and complete pHING distribution packs. If you want to modify the pHing, we recommend that you download the full phing package so you can create your own PEAR package. If you know Simply use paing as a need for the project or build other packages, download and install the PEAR package.
Get a copy of the development from CVS
Encourage you to contribute to the development of PHING. If you are interested in participating in the pHING or your knowledge is interested in the latest features, you can see the following description and get a copy from CVS.
The CVS revisions of Phing are not bullet-proof and may fail to execute properly on your machine. Only obtain the CVS versions if you are absolutely aware of limitations and constraints of such an action.Additionally you should sign up to the development mailinglist to report And NOTICE ERRORS AND INCOMPAMPATIBILITIES.
We assume that you are running a UNIX type operating system
So We Expect The CVS Software is Installed Ant The CVS Executable IS IN Your System's Search Path .. HoWever, The Steps for a Windows Based System Are Very Similar.
There is a large number of resources available to use CVS, and there are also CVS descriptions about the TIGRIS project management platform.
First of all, the first thing you have to do is to log in to the CVS server. Type: Type:
CVS -D: PServer: guest@cvs.tigris.org: / cvs login
If you want to log in as a developer to the TiGris Web site. Log in with your own username and password. You can also log in to the Tigris Web site as a visitors.
To pick out individual modules from the project source code repository (if you don't need the entire project repository), type:
CVS -D: PServer: guest@cvs.tigris.org/cvs checkout pHING
PEAR installation
The easiest way to install PHING is to use the PEAR installation tool.
$> pear install http://phing.info/pear/phing-current.tgz
PEAR Installation Tool will check the redeature of the package and put the PHING's execution script below the PHP installation directory (PEAR command script is also under this directory)
Non-PEAR installation (manual installation)
If you are not installed with a PEAR, you can install it yourself, but you have to complicate, you need to configure your environment variables to make the paing to find the pHING.BAT execution script. You can download from http://phing.tigris.org
PHING-2.0.0.0.2.tar.gz, unzipped to any directory, generate three directory bin, docs, and classes, then set the environment variable phing_home, point to the PHING directory.
For example: I downloaded Phing-2.0.0.tar.gz to decompress the d: / pHing, set the paing_home to D: / pHing.
Before running, you need to configure it.
1. Add $ pHING_HOME (* NIX) or% pHING_HOME% (Windows) to the PATH environment variable. 2. Setting the pHING_HOME environment variable points to the PHING installation directory.
3. Set the PHP_COMMAND variable to point to the location where the PHP command is located, for example (* NIX / USR / BIN / PHP) or Windows (C: /PHP5/Php.exe)
4. Set the PHP_CLASSPATH environment variable to include the pHING requires a quota library. At least% PHP_HOME% / Classes should be included.
Another way is to add% PHP_HOME% / Classes path to the include_path parameter in the php.ini file.
5. Check php.ini and make sure there is a set setting
a) nax_execution_time = 0 // is not limited
b) Memory_limit = 32MB // Due to the size of your build file, you may need more memory
Unix
If you use UNIX, use the Bash Bourne Shell, and PHING is installed in the / OPT / PHING directory
The environment is appropriately set by the following method.
Export php_command = / usr / bin / PHP
Export phing_home = / opt / pHING
EXPORT PHP_CLASSPATH = $ {phing_home} / classes
Export Path = $ {Path}: $ {phing_home} / bin
Windows
In the Windows platform, hypothesis phing is installed in a C: / OPT / PHING directory, then the configuration is entered:
SET PHP_COMMAND = C: /opt/php/php.exe
SET PHING_HOME = C: / OPT / PHING
Set php_classpath = C: / OPT / PHING / CLASSES
SET PATH =% PATH%;% paing_home% / bin
advanced
There are many variables used to run the pHING, you have at least the following settings:
1. If you want to pHING to use other packages / classes, then you have to add them to the php.ini file of the php.ini file in the php.ini file in the php_classpath variable.
2. Some tasks require third-party libraries.
Call phing
Now, you are ready to call the pHing in the command line or script. The following chapter briefly describes how to correctly implement the pHING
Command Line
PHING is also very simple in the command line. Switch to the directory where the build file is located and type:
phing [targetname]
Getting start
The phing build file is written in XML tag language, so you should have some basic knowledge of XML and AT to understand the following chapters, there are many resources available on the Web.
XML and PHING
The build file has the following basic structure:
1. Document preamble (Document ProLog)
2. Root elements
3. Several types of elements (
4. Contains one or several built-in or user-defined task elements (for example:
Write a simple build file
XML Version = "1.0"?>
target>
target>
target>
target>
provject>
Project elements
The first element following the file preamble is
Attribute meaning?
Name project name NO
The root directory of the BaseDir project, if not specified will use the current directory NO
DEFAULT When you call the build file, if you do not specify the target to be executed,
Project default targets that will be implemented here
Description of the Description project YES
Target element
A goal can rely on other goals. You may have a goal of installing a file in building a tree, for example, creating a tar.tgz distribution package.
Attributes of Target elements:
Attribute meaning requirements
Name target name YES
Depends Division List of comma-dependent comma-dependent
IF In order to make this goal to perform, the name NO of the attribute that must be set
Unless to make this goal to execute the name task element for disabled attributes
A task is a period of executable PHP code segment. This code segment implements a specific behavior (for example, copy file). So you must be defined in the build file to be pHING real calls it.
Appendix has a set of core tasks and many optional tasks. It is also easy to write your own task (extended the feet).
Task can be assigned an ID attribute:
Property element
The attribute is the basic variable used by building a file, which can be set through the PropertyTask task settings in the build file or passed through the command line outside. Attributes passing through the command line always override the properties set in the build file, that is, The command line is finally passed to the pHING, which naturally overrides the properties of the previously built in the build file.
The property has a name and a unique value. The property can be used as a value of the task properties. This is set by "$ {" and "}" containing the attribute name. For example:
Here is running at runtime $ {javasourcedir} to be expanded to ./src/java
Internal apparatus
PHING provides you with the ability to access the system properties, as if it has been defined by
More complex build files
XML Version = "1.0"?>
fileset>
copy>
target>
target>
provject>
Building a file first uses the
The previous five elements define the properties of the project. (Three different points according to the way of access)
1. (Environment Variable) The first Property element, has an attribute Environment property, which is an ENV so that the environment variable can be accessed by env.variable_name. For example, I can call the echo task env.path variable printing Console output:
This will output a string of the PATH environment variable.
2. (File) The second ProPERY element contains only the file attribute, where the value of the file attribute is a relative or absolute point to the path to the properties file (the property file: the suffix is called .properties, the key value "containing (Key) The collection of / value), see Appendix E) in the format.
3. (Define attribute variables directly in building files) to define:
Also note that the
Translator Note: In fact,
Regarding the file set, see Appendix C has a more detailed description. In addition, the
The first task only contains the CopyTask task that is called via the
In the second goal, use the
Setting with phing
The goal of this chapter is the past and correct settings and executes phing on your operating system, you don't have to go back to the head with installation. Unless you want to reinstall or transplant it to other platforms.
System Requirements
operating system
To use phing, you must install PHP
Version 5.0.0B1 and above and plus -with-libxml2, and -with-xsl options.
If you want to make use of advanced functionality. at the time of write php
5.0.0B2-Dev Is Currently Unable to Run PHING Due To Segmentation Faults Arising Somewhere In The Xml Parsing of The Build File.
For PHP and its requirements module, please see the PHP website http://www.php.net For a brief software dependence list as follows
Project component
The goal of this chapter is to make you familiarize yourself with the basic components of building a file. After reading this chapter, even if you don't know the build file; you can read, and understand the basic structure of building a file. For additional reference information, you can view Appendix A, Appendix B, Appendix C, Appendix D.
PROJECT
In the project file structure, you must define the
XML Version = "
1.0 "?>
provject>
The three properties of Project, the Name-Project Name, this is a must, the Description-Project brief description, default- If the target is not specified, the default target of the project will be used.
Project Components in General
Item Components is the tag of all description item information you can find in the project file. The target is the project component, and there are tasks, types, and more. Project components may have properties and nested tags. Attributes only contain simple values, Such as strings, integers, and so on. Nested elements can be complex pHING types (such as FileSets) or simple values package classes (Wrapper Classes)
Write a map
Create a mapper
Writing a file mappper in PHP5 is simplified by the interface supported by PHP5. Essentially, your custom file name Mapper must implement the pHING.MAPPERS.FILENAMAPPERS interface. There is a file name that creates a DOS file name style Mapper
Appendix A
HING internal apparatus
Attribute content
Application.startdir
Host.arch host name. Not available on Windows
Host.Doman DNS domain name. For example, php.net. Not available in Windows
Host.fstype file system type, possible value of Unix, WinNT, Win32.
Host.Machine system architecture. For example, I586. Not available in Windows
Host.name is not available on Windows by POST.NAME.
Host.os.Release operating system is publishing, such as 2.2.10, not available on Windows
Host.os.version operating system version, # 4 tue jul 20 17:01:36 mest 1999. Not available on Windows
Lince.seParetor line division, Unix "/ n", Windows is "/ r / n", Macintosh is "/ R"
PHP.CLASSPATH PHP_CLASSPATH environment variable value.
The version of the PHP.Version PHP interpreter.
PHING.BUILDFILE Current path to build files
PHING.ID
PHING.VERSION current PHING version
Project.name Current Project Name
Project.basedir Current Project Root Path
Project.description current project description
User.home Environment Variable HOME
Appendix B Core Mission
AdhocTaskDeftask
AdhocTypedEftask
Appendtask
Availabletask
CallTargettask
COPYTASK
Deletetask
ECHOTASKEXECTASK
Foreachtask
Inputtask
MKDIRTASK
Movetask
PHINGTASK
PearpackageTask
Phpevaltask
PropertyTask
ReflexievTask
ResolvePathtask
Artask
askDEFTASK
TouchTask
TypeDeftask
UptodateTask
Xslttask
Appendix C Core Type
This is a reference for a pHING system data type
FileList file list
FileList data type, just like the name of its name, unlike FileSets, filelist can include files that have not yet created, it is not in the file system. The same FileList can describe files in the specified order, but the fileset returned from the file system is indeed unordered.
Use example
Or use a list file (Listfile property), each line contains a file name
This will take each line in the INI_FILES.TXT file to return to the filelist
Attributes
Name Type Description DEFAULT REQUIRED
DIR STRING FILES and LISTFILE pointed out directory N / A YES
Files string comma or space separated file list N / a yes (or listfile)
Listfile string a text file representing a list of files,
Each line represents a file n / a yes (or files)
PATH / CLASSPATH
Core Filters
PHING FILTER Reader
Expand Properties
HEADFILTER
LineContains
LineContains Regexp
Prefix Lines
Replace tokens
Replaceregexp
Striplinebreaks
StriplineComments
StripphpComments
Tabtospace
TAILFILTER
XSLTFilter
Core mappers
Flattenmapper
GLOBMAPPER
IdentityMapper
Ergemapper
Regexpmapper
Appendix D Project Component
PHING project
Projects is the outermost container element of the project in the build file, and
The project can contain task calls and targets. (As follows)
example:
Description = "this is a test project to show how to use supplies"> provject> Attributes Name Type Description Default Basedir string project root directory N / A YESDEFAULT string If not specified at the command line, Will use the default target all NO Description string project simple description N / A NO Name string item Name N / A YES aims example: Description = "this is a example target"> target> This goal defined in the above example is only executed when the attribute lang is set and the attribute lang.en is not set, and it rely on both of the Foo1 and Foo2 objectives, which means two goals for Foo1 and Foo2 before the main target execution. The name of the target is MIAN and has a simple description. Name Type Description Default Depends String the current goal, the goal, If there are multiple dependent targets, separated by a comma N / A NO Description String About the short description of the target N / A NO If String must set the attribute N / A NO Unless String N / A NO Name String target name N / a yes Appendix E File Format Build file format The following XML file displays a skeleton for building a file, which contains only a project and a target element. About how to use them to view information about paing types and tasks. XML Version = ' 1.0 '?>
THE ROOT TAG OF Each Build File Must Be a "Project" tag. -> [Default = ""] [Description = "]>
Type and Task Calls Here, I.E. FileSets, Patternsets, CopyTask Calls ETC. -> [if = "] [unlessproperty"]>
Type and Task Calls Here, I.E. FileSets, Patternsets, CopyTask Calls, ETC. -> target>
-> provject> Property file format The property file defines the properties. The property saves in the form of key / value, and only the plain text, the suffix name of the property file is generally .properties, the default properties file for building the file is build.properties # Property Files Contain Key / Value PAIRS Key = Value # Property Keys May Contain Alpha_UMeric Chars and Colons, But # NOT Special Chars. This Way You Create Pseudo-Namespaces myapp.window.hsize = 300 myapp.window.vsize = 200 myapp.window.xpos = 10 myapp.window.ypos = 100 # You can refer to value of other prints by enclosing their # Keys in "$ {}". TEXT.WIDTH = $ {myapp.window.hsize} # Everything behind The equal sign is the value, you do # NOT HAVE to Enclose Strings: Text = this is some text, your os IS $ {php.OS} # I Guess That Is All There Is To Property Files Reference International standard [OSI-Model] OSI (Open System Interconnect) model http://www.iso.org http://www.instantweb.com/foldoc/foldoc.cgi?osi [XML10-Spec] W 3C XML 1.0 specification http://www.w3.org/xml/ [unicode] Unicode http://www.unicode.org license [GNU-LGPL] The GPL (GNU Lesser Public License) http://www.gnu.org/license/lgpl.html [gnu-fdl] The GNU FDL (Free Documentation License), The License Used for this Documentation http://www.gnu.org/licenses/fdl.html Open source project [bc] Binarycloud http://www.binarycloud.com http://binarycloud.tigris.org [w 3c-tidy] HTMLTIDY, A W 3c (x) html and xml syntax checker and code beautyfier http://www.w 3c.org/people/ragget/tidy/ [phpdoc] PHPDOC project http://www.phpdoc.de [phpclasses] Manuel Lemos PHPClasses Resource Library http://www.phpclasses.org [pear] PEAR (PHP Extension Archive Repository) PHP Extension http://pear.php.net [ANT] Ant, A Java Build Tool, The Main Inspiration for PHING http://ant.apache.org [gnumake] GNU Make, An Inspiration for PHING http://www.gnu.org/software/make/make.html[pollo] Pollo, a Visual Editor for XML Files. A Schema to Edit Phes Build Files Is Shipped with pHING. http://pollo.sourceforge.net [gingerall] Ginger Alliance - Home of Sablotorn http://www.gingerall.com [php] PHP official homepage PHP Hypertext Preprocessor http://www.php.net [gnu] GNU (GNU's Not UNIX) organization http://www.gnu.org [pHING] PHING (PHING IS NOT GNUMAKE) homepage http://phing.info [cvs-howto] Short Manuals for CVS Http://www.ucolick.org/~de/cvsbeginner.html [CVS-TIGRIS] CVS and Tigris.org Http://binarycloud.tigris.org/project/www/docs/ddusingcvs_command-line.html Other resources [javadoc] Sun javadoc http://java.sun.com/j2se/javadoc/ [Zend] Zend Technologies, Ltd. http://www.zend.com manual M T T P