LinuxCommandLibrary

phing

Automate software build and deployment processes

TLDR

Perform the default task in the build.xml file

$ phing
copy

Initialize a new build file
$ phing [[-i|--init]] [path/to/build.xml]
copy

Perform a specific task
$ phing [task_name]
copy

Use the given build file path
$ phing [[-f|-buildfile]] [path/to/build.xml] [task_name]
copy

Log to the given file
$ phing -logfile [path/to/log_file] [task_name]
copy

Use custom properties in the build
$ phing -D[property]=[value] [task_name]
copy

Specify a custom listener class
$ phing -listener [class_name] [task_name]
copy

Build using verbose output
$ phing -verbose [task_name]
copy

SYNOPSIS

phing [OPTIONS] [TARGET [TARGET2 ...]]
phing -f BUILD_FILE [TARGET]
phing -l

PARAMETERS

TARGET
    Specifies one or more build targets to execute. If no target is specified, the default target defined in the buildfile will be executed.

-f, --buildfile <file>
    Uses the specified XML build file instead of the default build.xml.

-D<property>=<value>, --define <property>=<value>
    Defines a property on the command line. These properties can then be used within the buildfile.

-l, --list
    Lists all available targets and their descriptions from the current buildfile.

-v, --verbose
    Produces verbose output, showing more details about the build process and task execution.

-q, --quiet
    Suppresses normal output, showing only errors and warnings.

-S, --simplelog
    Uses a simple logging format for output, often preferred for CI environments.

-logger <class>
    Specifies a custom logger class to be used for output logging.

-propertyfile <file>
    Loads properties from the specified .properties file into the build environment.

-find <file>
    Searches for the specified build file (defaulting to build.xml) in the current directory and parent directories.

-version
    Prints the Phing version information.

-h, --help
    Displays a help message with available command-line options.

DESCRIPTION

Phing is an open-source, PHP-based project build system inspired by Apache Ant. It provides a robust framework for automating common tasks involved in software development, such as compiling code (e.g., Less/Sass), running tests, generating documentation, packaging releases, and deploying applications. Instead of writing shell scripts for each task, Phing uses XML buildfiles (typically build.xml) to define a project's targets and the tasks required to achieve them. This approach offers cross-platform compatibility and simplifies complex workflows into manageable, reusable steps. Its extensibility allows developers to create custom tasks in PHP, integrating seamlessly with existing PHP codebases and libraries, making it a powerful tool for continuous integration and delivery pipelines in PHP projects.

CAVEATS

Phing requires a PHP runtime environment to operate. While its XML-based configuration provides structure, it can become verbose for very simple tasks or, conversely, complex for highly customized workflows, potentially leading to a steeper learning curve compared to simple shell scripting. Managing dependencies (e.g., external binaries) used by Phing tasks needs careful setup outside of Phing itself.

BUILDFILES

A Phing build is defined in an XML file, typically named build.xml. This file consists of a root <project> element, which contains one or more <target> elements. Each <target> defines a specific set of actions, and these actions are performed by various <task> elements. Targets can have dependencies on other targets, allowing for complex, ordered execution flows.

TASKS

Phing provides a rich library of built-in tasks for common operations like file manipulation (copy, delete, move), executing shell commands, running PHPUnit tests, interacting with version control systems, and more. The power of Phing also lies in its extensibility, allowing developers to write custom tasks in PHP to encapsulate project-specific logic or integrate with third-party tools not covered by the default task library.

HISTORY

Phing was conceived around 2004-2005 by Michiel Rook, largely inspired by Apache Ant, a Java-based build tool. The goal was to provide a similar robust, extensible build automation system specifically for PHP projects, leveraging PHP's own capabilities. Over the years, it gained significant traction within the PHP community, evolving with the language and its ecosystem. It continues to be actively maintained, providing a stable and flexible solution for automating diverse tasks in PHP development workflows.

SEE ALSO

make(1), ant(1), composer(1)

Copied to clipboard