Classes, interfaces and traits
AdhocTask¶
Abstract class for creating adhoc Phing components in buildfile.
By itself this class can be used to declare a single class within your buildfile.
You can then reference this class in any task that takes custom classes (selectors,
mappers, filters, etc.)
Subclasses exist for conveniently declaring and registering tasks and types.
« More »
AdhocTaskdefTask¶
A class for creating adhoc tasks in build file.
<target name="test-adhoc">
<adhoc-task name="foo"><![CDATA[
class FooTest extends Task {
private $bar;
function setBar($bar) {
$this->bar = $bar;
}
function main() {
$this->log("In FooTest: " . $this->bar);
}
}
]]></adhoc-task>
<foo bar="B.L.I.N.G"/>
</target>
« More »
AdhocTypedefTask¶
A class for creating adhoc datatypes in build file.
By itself this class can be used to declare a single class within your buildfile.
You can then reference this class in any task that takes custom classes (selectors,
mappers, filters, etc.)
Subclasses exist for conveniently declaring and registering tasks and types.
« More »
AppendTask¶
Appends text, contents of a file or set of files defined by a filelist to a destination file.
<code>
<append text="And another thing\n" destfile="badthings.log"/>
</code>
OR
<code>
<append file="header.html" destfile="fullpage.html"/>
<append file="body.html" destfile="fullpage.html"/>
<append file="footer.html" destfile="fullpage.html"/>
</code>
OR
<code>
<append destfile="${process.outputfile}">
<filterchain>
<xsltfilter style="${process.stylesheet}">
<param name="mode" expression="${process.xslt.mode}"/>
<param name="file_name" expression="%{task.append.current_file.basename}"/> <!-- Example of using a RegisterSlot variable -->
</xsltfilter>
</filterchain>
<filelist dir="book/" listfile="book/PhingGuide.book"/>
</append>
</code>
« More »
ApplyTask¶
Executes a command on the (filtered) file list/set.
(Loosely based on the "Ant Apply" task - http://ant.apache.org/manual/Tasks/apply.html)
« More »
AttribTask¶
Changes the attributes of a file or all files inside specified directories.
Right now it has effect only under Windows. Each of the 4 possible
permissions has its own attribute, matching the arguments for the `attrib`
command.
Example:
```
<attrib file="${input}" readonly="true" hidden="true" verbose="true"/>
```
« More »
AvailableTask¶
<available> task.
Note: implements condition interface (see condition/Condition.php)
« More »
Basename¶
Task that changes the permissions on a file/directory.
Use \Project#createTask to register a new Task.
« More »
BlockForTask¶
Based on Apache Ant Block For:
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
« More »
CaseTask¶
"Inner" class for SwitchTask.
The sequential task has no attributes and does not support any nested
elements apart from Ant tasks. Any valid Ant task may be embedded within the
sequential task.
« More »
ChmodTask¶
Task that changes the permissions on a file/directory.
Use \Project#createTask to register a new Task.
« More »
ChownTask¶
Task that changes the permissions on a file/directory.
Use \Project#createTask to register a new Task.
« More »
ConditionTask¶
<condition> task as a generalization of <available>
<p>This task supports boolean logic as well as pluggable conditions
to decide, whether a property should be set.</p>
<p>This task does not extend Task to take advantage of
ConditionBase.</p>
« More »
CopyTask¶
A phing copy task. Copies a file or directory to a new file
or directory. Files are only copied if the source file is newer
than the destination file, or when the destination file does not
exist. It is possible to explicitly overwrite existing files.
Use \Project#createTask to register a new Task.
« More »
CreoleTask¶
Handles Creole configuration needed by SQL type tasks.
Use \Project#createTask to register a new Task.
« More »
CvsPassTask¶
Adds an new entry to a CVS password file.
Use \Project#createTask to register a new Task.
« More »
CvsTask¶
Task for performing CVS operations.
NOTE: This implementation has been moved here from Cvs.java with
the addition of some accessors for extensibility. Another task
can extend this with some customized output processing.
« More »
DeleteTask¶
Deletes a file or directory, or set of files defined by a fileset.
Use \Project#createTask to register a new Task.
« More »
DiagnosticsTask¶
This is a task that hands off work to the Diagnostics module.
It lets you run diagnostics in an IDE.
« More »
Dirname¶
Determines the directory name of the specified file.
This task can accept the following attributes:
<ul>
<li>file
<li>property
</ul>
Both <b>file</b> and <b>property</b> are required.
<p>
When this task executes, it will set the specified property to the
value of the specified file up to, but not including, the last path
element. If file is a file, the directory will be the current
directory.
« More »
EchoProperties¶
Displays all the current properties in the build. The output can be sent to
a file if desired.
Attribute "destfile" defines a file to send the properties to. This can be
processed as a standard property file later.
Attribute "prefix" defines a prefix which is used to filter the properties
only those properties starting with this prefix will be echoed.
By default, the "failonerror" attribute is enabled. If an error occurs while
writing the properties to a file, and this attribute is enabled, then a
BuildException will be thrown. If disabled, then IO errors will be reported
as a log statement, but no error will be thrown.
Examples: <pre>
<echoproperties />
</pre> Report the current properties to the log.
<pre>
<echoproperties destfile="my.properties" />
</pre> Report the current properties to the file "my.properties", and will
fail the build if the file could not be created or written to.
<pre>
<echoproperties destfile="my.properties" failonerror="false"
prefix="phing" />
</pre> Report all properties beginning with 'phing' to the file
"my.properties", and will log a message if the file could not be created or
written to, but will still allow the build to continue.
« More »
EchoTask¶
Echos a message to the logging system or to a file
Use \Project#createTask to register a new Task.
« More »
ElseIfTask¶
"Inner" class for IfTask.
This class has same basic structure as the IfTask, although of course it doesn't support <else> tags.
« More »
ExecTask¶
Executes a command on the shell.
Use \Project#createTask to register a new Task.
« More »
FailTask¶
Exits the active build, giving an additional message
if available.
Use \Project#createTask to register a new Task.
« More »
ForeachTask¶
<foreach> task
Task definition for the foreach task. This task takes a list with
delimited values, and executes a target with set param.
Usage:
<foreach list="values" target="targ" param="name" delimiter="|" />
Attributes:
list --> The list of values to process, with the delimiter character,
indicated by the "delimiter" attribute, separating each value.
target --> The target to call for each token, passing the token as the
parameter with the name indicated by the "param" attribute.
param --> The name of the parameter to pass the tokens in as to the
target.
delimiter --> The delimiter string that separates the values in the "list"
parameter. The default is ",".
« More »
FunctionParam¶
Supports the <param> nested tag for PhpTask.
« More »
IfTask¶
Perform some tasks based on whether a given condition holds true or
not.
<p>This task is heavily based on the Condition framework that can
be found in Ant 1.4 and later, therefore it cannot be used in
conjunction with versions of Ant prior to 1.4.</p>
<p>This task doesn't have any attributes, the condition to test is
specified by a nested element - see the documentation of your
<code><condition></code> task (see
<a href="http://jakarta.apache.org/ant/manual/CoreTasks/condition.html">the
online documentation</a> for example) for a complete list of nested
elements.</p>
<p>Just like the <code><condition></code> task, only a single
condition can be specified - you combine them using
<code><and></code> or <code><or></code> conditions.</p>
<p>In addition to the condition, you can specify three different
child elements, <code><elseif></code>, <code><then></code> and
<code><else></code>. All three subelements are optional.
Both <code><then></code> and <code><else></code> must not be
used more than once inside the if task. Both are
containers for Ant tasks, just like Ant's
<code><parallel></code> and <code><sequential></code>
tasks - in fact they are implemented using the same class as Ant's
<code><sequential></code> task.</p>
The <code><elseif></code> behaves exactly like an <code><if></code>
except that it cannot contain the <code><else></code> element
inside of it. You may specify as may of these as you like, and the
order they are specified is the order they are evaluated in. If the
condition on the <code><if></code> is false, then the first
<code><elseif></code> who's conditional evaluates to true
will be executed. The <code><else></code> will be executed
only if the <code><if></code> and all <code><elseif></code>
conditions are false.
<p>Use the following task to define the <code><if></code>
task before you use it the first time:</p>
<pre><code>
<taskdef name="if" classname="net.sf.antcontrib.logic.IfTask" />
</code></pre>
<h3>Crude Example</h3>
<code>
<if>
<equals arg1="${foo}" arg2="bar" />
<then>
<echo message="The value of property foo is bar" />
</then>
<else>
<echo message="The value of property foo is not bar" />
</else>
</if>
</code>
<code>
<if>
<equals arg1="${foo}" arg2="bar" />
<then>
<echo message="The value of property foo is 'bar'" />
</then>
<elseif>
<equals arg1="${foo}" arg2="foo" />
<then>
<echo message="The value of property foo is 'foo'" />
</then>
</elseif>
<else>
<echo message="The value of property foo is not 'foo' or 'bar'" />
</else>
</if>
</code>
« More »
ImportTask¶
Imports another build file into the current project.
Targets and properties of the imported file can be overrridden
by targets and properties of the same name declared in the importing file.
The imported file will have a new synthetic property of
"phing.file.<projectname>" declared which gives the full path to the
imported file. Additionally each target in the imported file will be
declared twice: once with the normal name and once with "<projectname>."
prepended. The "<projectname>.<targetname>" synthetic targets allow the
importing file a mechanism to call the imported files targets as
dependencies or via the <phing> or <phingcall> task mechanisms.
« More »
IncludePathTask¶
Adds a normalized path to the PHP include_path.
This provides a way to alter the include_path without editing any global php.ini settings
or PHP_CLASSPATH environment variable.
<code>
<includepath classpath="new/path/here"/>
</code>
« More »
IsFailure¶
Condition to test a return-code for failure.
« More »
MatchingTask¶
This is an abstract task that should be used by all those tasks that
require to include or exclude files based on pattern matching.
This is very closely based on the ANT class of the same name.
« More »
MkdirTask¶
Task to create a directory.
Use \Project#createTask to register a new Task.
« More »
MoveTask¶
Moves a file or directory to a new file or directory.
By default, the destination file is overwritten if it
already exists. When overwrite is turned off, then files
are only moved if the source file is newer than the
destination file, or when the destination file does not
exist.
Source files and directories are only deleted when the file or
directory has been copied to the destination successfully.
« More »
PathConvert¶
Converts path and classpath information to a specific target OS
format. The resulting formatted path is placed into the specified property.
Use \Project#createTask to register a new Task.
« More »
PDOTask¶
Handles PDO configuration needed by SQL type tasks.
Use \Project#createTask to register a new Task.
« More »
PhingCallTask¶
Call another target in the same project.
<samp>
<target name="foo">
<phingcall target="bar">
<property name="property1" value="aaaaa" />
<property name="foo" value="baz" />
</phingcall>
</target>
<target name="bar" depends="init">
<echo message="prop is ${property1} ${foo}" />
</target>
</samp>
This only works as expected if neither property1 nor foo are defined in the project itself.
« More »
PhingReference¶
Helper class that implements the nested <reference>
element of <phing> and <phingcall>.
« More »
PhingTask¶
Task that invokes phing on another build file.
Use this task, for example, if you have nested buildfiles in your project. Unlike
AntTask, PhingTask can even support filesets:
<pre>
<phing>
<fileset dir="${srcdir}">
<include name="** /build.xml" /> <!-- space added after ** is there because of PHP comment syntax -->
<exclude name="build.xml" />
</fileset>
</phing>
</pre>
« More »
PhingVersion¶
An phing version condition/task.
Use \Project#createTask to register a new Task.
« More »
PhpEvalTask¶
Executes PHP function or evaluates expression and sets return value to a property.
WARNING:
This task can, of course, be abused with devastating effects. E.g. do not
modify internal Phing classes unless you know what you are doing.
« More »
PropertyPromptTask¶
Deprecated task that uses console to prompt user for property values.
This class is very slightly simpler than the InputTask, but lacks the ability
to use a non-console input handler. You should, therefore, use InputTask. This
class can serve as a reference, but will be removed in the future.
« More »
PropertyTask¶
Task for setting properties in buildfiles.
Use \Project#createTask to register a new Task.
« More »
RecorderEntry¶
This is a class that represents a recorder. This is the listener to the
build process.
« More »
RecorderTask¶
Adds a listener to the current build process that records the
output to a file.
<p>Several recorders can exist at the same time. Each recorder is
associated with a file. The filename is used as a unique identifier for
the recorders. The first call to the recorder task with an unused filename
will create a recorder (using the parameters provided) and add it to the
listeners of the build. All subsequent calls to the recorder task using
this filename will modify that recorders state (recording or not) or other
properties (like logging level).</p>
<p>Some technical issues: the file's print stream is flushed for "finished"
events (buildFinished, targetFinished and taskFinished), and is closed on
a buildFinished event.</p>
« More »
ReflexiveTask¶
This task is for using filter chains to make changes to files and overwrite the original files.
This task was created to serve the need for "cleanup" tasks -- e.g. a ReplaceRegexp task or strip task
being used to modify files and then overwrite the modified files. In many (most?) cases you probably
should just use a copy task to preserve the original source files, but this task supports situations
where there is no src vs. build directory, and modifying source files is actually desired.
<code>
<reflexive>
<fileset dir=".">
<include pattern="*.html">
</fileset>
<filterchain>
<replaceregexp>
<regexp pattern="\n\r" replace="\n"/>
</replaceregexp>
</filterchain>
</reflexive>
</code>
« More »
ReplaceRegexpTask¶
ReplaceRegExp is a directory based task for replacing the occurrence of a
given regular expression with a substitution pattern in a selected file or
set of files.
<code>
<replaceregexp file="${src}/build.properties"
match="OldProperty=(.*)"
replace="NewProperty=\1"
byline="true"/>
</code>
« More »
ResolvePathTask¶
Task for resolving relative paths and setting absolute path in property value.
This task was created to address a need for resolving absolute paths of files / directories.
In many cases a relative directory (e.g. "./build") is specified, but it needs to be treated
as an absolute path since other build files (e.g. in subdirs) should all be using the same
path -- and not treating it as a relative path to their own directory.
<code>
<property name="relative_path" value="./dirname"/>
<resolvepath propertyName="absolute_path" file="${relative_path}"/>
<echo>Resolved [absolute] path: ${absolute_path}</echo>
</code>
TODO:
- Possibly integrate this with PackageAsPath, for handling/resolving dot-path paths.
« More »
Retry¶
Retries the nested task a set number of times.
Use \Project#createTask to register a new Task.
« More »
SequentialTask¶
Sequential is a container task that contains other Phing Task objects.
The sequential task has no attributes and does not support any nested
elements apart from Ant tasks. Any valid Ant task may be embedded within the
sequential task.
« More »
SleepTask¶
A phing sleep task.
<p>A task for sleeping a short period of time, useful when a
build or deployment process requires an interval between tasks.</p>
<p>A negative value can be supplied to any of attributes provided the total sleep time
is positive, pending fundamental changes in physics and PHP execution times.</p>
<p>Note that sleep times are always hints to be interpreted by the OS how it feels
small times may either be ignored or rounded up to a minimum timeslice. Note
also that the system clocks often have a fairly low granularity too, which complicates
measuring how long a sleep actually took.</p>
« More »
SwitchTask¶
Task definition for the phing task to switch on a particular value.
Task calling syntax:
```
<switch value="value" [caseinsensitive="true|false"] >
<case value="val">
<property name="propname" value="propvalue" /> |
<phingcall target="targetname" /> |
any other tasks
</case>
[
<default>
<property name="propname" value="propvalue" /> |
<phingcall target="targetname" /> |
any other tasks
</default>
]
</switch>
```
Attributes:
value -> The value to switch on
caseinsensitive -> Should we do case insensitive comparisons?
(default is false)
Subitems:
case --> An individual case to consider, if the value that
is being switched on matches to value attribute of
the case, then the nested tasks will be executed.
default --> The default case for when no match is found.
Crude Example:
```
<switch value="${foo}">
<case value="bar">
<echo message="The value of property foo is bar" />
</case>
<case value="baz">
<echo message="The value of property foo is baz" />
</case>
<default>
<echo message="The value of property foo is not sensible" />
</default>
</switch>
```
« More »
TaskdefTask¶
Register a task for use within a buildfile.
This is for registering your own tasks -- or any non-core Task -- for use within a buildfile.
If you find that you are using a particular class frequently, you may want to edit the
phing/tasks/defaults.properties file so that it is included by default. You may also
want to submit it (if LGPL or compatible license) to be included in Phing distribution.
<pre>
<taskdef name="mytag" classname="path.to.MyHandlingClass"/>
.
.
<mytag param1="val1" param2="val2"/>
</pre>
TODO:
-- possibly refactor since this is almost the same as TypeDefTask
(right now these are just too simple to really justify creating an abstract class)
« More »
TempFile¶
This task sets a property to the name of a temporary file.
Unlike [PhingFile::createTempFile()](../classes/PhingFile.html#method_createTempFile), this task does not (by default) actually create the
temporary file, but it does guarantee that the file did not
exist when the task was executed.
Examples:
`<tempfile property="temp.file" />`
create a temporary file
`<tempfile property="temp.file" suffix=".xml" />`
create a temporary file with the .xml suffix.
`<tempfile property="temp.file" destDir="build"/>`
create a temp file in the build subdir
« More »
ThrowTask¶
Exits the active build, giving an additional message
if available.
Use \Project#createTask to register a new Task.
« More »
TouchTask¶
Touch a file and/or fileset(s); corresponds to the Unix touch command.
If the file to touch doesn't exist, an empty one is created.
« More »
TruncateTask¶
The base class for all Tasks.
Use \Project#createTask to register a new Task.
« More »
TryCatchTask¶
A wrapper task that lets you run tasks(s) when another set
of tasks fails.
Inspired by [http://ant-contrib.sourceforge.net/tasks/tasks/trycatch.html](http://ant-contrib.sourceforge.net/tasks/tasks/trycatch.html)
« More »
TstampTask¶
Sets properties to the current time, or offsets from the current time.
The default properties are TSTAMP, DSTAMP and TODAY;
Based on Ant's Tstamp task.
« More »
TypedefTask¶
Register a datatype for use within a buildfile.
This is for registering your own datatypes for use within a buildfile.
If you find that you are using a particular class frequently, you may want to edit the
phing/types/defaults.properties file so that it is included by default. You may also
want to submit it (if LGPL or compatible license) to be included in Phing distribution.
<pre>
<typedef name="mytype" classname="path.to.MyHandlingClass"/>
.
<sometask ...>
<mytype param1="val1" param2="val2"/>
</sometask>
</pre>
TODO:
-- possibly refactor since this is almost the same as TaskDefTask
(right now these are just too simple to really justify creating an abstract class)
« More »
UpToDateTask¶
Sets the given property if the specified target has a timestamp
greater than all of the source files.
Use \Project#createTask to register a new Task.
« More »
WaitForTask¶
Based on Apache Ant Wait For:
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
« More »
WarnTask¶
Simple task to echo a warning message (Project::MSG_WARN) to all output devices.
Use \Project#createTask to register a new Task.
« More »
XsltTask¶
Implements an XSLT processing filter while copying files.
This is a shortcut for calling the <copy> task with the XSLTFilter used
in the <filterchains> section.
« More »