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 [target3] ...]]

PARAMETERS

-f file
    Use specified buildfile

-l
    List targets in this project (short format)

-L
    List targets in this project (long format)

-p
    Print project help information

-v
    Be verbose

-q
    Be less verbose

-debug
    Print debugging information

-emacs
    Produce logging information without adornments

-keep-going
    Execute all targets that do not depend on failed target(s)

-propertyfile file
    Load all properties from file with -D overrides

-D property=value
    Use value for given property

-logger class
    The classname of the logger to use. Default is phing.listener.DefaultLogger

-listener class
    Add an instance of class as a project listener

-allow-recursion
    allow buildfiles to call other buildfiles (recursive builds)

-inputhandler class
    The classname of the InputHandler to use

-autodiscovery
    indicates whether to look for buildfiles in the current folder if none is specified

-nice value
    A niceness value to add to any forked JVM processes

-version
    Print the version information and exit

-h
    Help message

DESCRIPTION

Phing is a PHP-based build system inspired by Apache Ant. It provides a simple XML-based project configuration file to define build targets and tasks, enabling automated build processes for PHP projects. Phing can handle tasks such as code copying, file manipulation, unit testing (using PHPUnit), documentation generation (using PHPDocumentor), and deployment. It allows developers to define dependencies and execute tasks in a specific order. By using Phing, developers can streamline and standardize the build process, ensuring consistency and repeatability across different environments. It simplifies complex deployment scenarios and promotes best practices for software development.
Phing provides a flexible and extensible framework. Custom tasks can be created to support specific needs. Phing aims to provide a powerful and easy-to-use way to manage all aspects of building, testing, and deploying PHP applications.

BUILDFILE STRUCTURE

A Phing buildfile is typically named `build.xml` and contains a project element, properties, targets, and tasks.
The project element defines the project's name and default target.
Properties are used to define variables, and targets represent distinct build phases. Tasks are the actual operations performed within a target.

TASKS

Phing provides a wide range of built-in tasks for file manipulation, execution of external programs, and integration with other tools. Some commonly used tasks include `copy`, `delete`, `exec`, `mkdir`, `phpunit`, and `phploc`. Custom tasks can be created in PHP to extend Phing's functionality.

EXAMPLE

A simple example would be using Phing to copy and minify js files
phing -f build.xml minify_js

Copied to clipboard