5.4 Targets

Targets are collections of project components (but not other targets) that are assigned a unique name within their project. A target generally performs a specific task -- or calls other targets that perform specific tasks -- and therefore a target is a bit like a function (but a target has no return value).

Targets may depend on other targets. For example, if target A depends on a target B, then when target A is called to be executed, target B will be executed first. Phing automatically resolves these dependencies. You cannot have circular references like: "target A depends on target B that depends on target A".

The following code snippet shows an example of the use of targets.

<target name="othertask" depends="buildpage" description="Whatever">
  <!-- Task calls here -->
<target>

<target name="buildpage" description="Some description">
  <!-- Task calls here -->
<target>

When Phing is asked to execute the othertask target, it will see the dependency and execute buildpage first. Notice that the dependency task can be defined after the dependent task.