Entry point into Phing.

This class handles the full lifecycle of a build -- from parsing & handling commandline arguments to assembling the project to shutting down and cleaning up in the end.

If you are invoking Phing from an external application, this is still the class to use. Your applicaiton can invoke the start() method, passing any commandline arguments or additional properties.

author | Andreas Aderhold
author | Hans Lellelid
version | $Id: 9d949a45b45bd04264dde71edde4424a7840a4ad $
package | phing

### Methods

## Import a PHP file

    __import(string $path, mixed $classpath)

Static

### Parameters

#### $path

`string`

Path to the PHP file

#### $classpath

`mixed`

String or object supporting __toString()

### Exceptions

`\BuildException` | - if cannot find the specified file

## Clears the captured errors without affecting the starting/stopping of the capture.

    clearCapturedPhpErrors()

Static

## currentTimeMillis()

    currentTimeMillis()

Static

## Setup/initialize Phing environment from commandline args.

    execute(array $args) : void

### Parameters

#### $args

`array`

commandline args passed to phing shell.

## Command line entry point.

    fire(array $args) : void

Static

This method kicks off the building of a project object and executes a build using either a given target or the default target.

### Parameters

#### $args

`array`

Command line args.

## Gets any PHP errors that were captured to buffer.

    getCapturedPhpErrors() : array

Static

### Returns

`array`array('message' => message, 'line' => line number, 'file' => file name, 'level' => error level)

## Gets the current Project.

    getCurrentProject() : \Project

Static

### Returns

`\Project`Current Project or NULL if none is set yet/still.

## This gets a property that was set via command line or otherwise passed into Phing.

    getDefinedProperty(string $name) : string

Static

"Defined" in this case means "externally defined". The reason this method exists is to provide a public means of accessing commandline properties for (e.g.) logger or listener scripts. E.g. to specify which logfile to use, PearLogger needs to be able to access the pear.log.name property.

### Parameters

#### $name

`string`

### Returns

`string`value of found property (or null, if none found).

## Gets the stream to use for error output.

    getErrorStream() : \OutputStream

Static

### Returns

`\OutputStream`

## Making output level a static property so that this property can be accessed by other parts of the system, enabling us to display more information -- e.g.

    getMsgOutputLevel() : int

Static

backtraces -- for "debug" level.

### Returns

`int`

## Gets the stream to use for standard (non-error) output.

    getOutputStream() : \OutputStream

Static

### Returns

`\OutputStream`

## Gets the current Phing version based on VERSION.TXT file.

    getPhingVersion() : string

Static

### Exceptions

`\BuildException` | - if unable to find version file.

### Returns

`string`

## Retuns reference to all properties

    getProperties()

Static

## Returns property value for a System property.

    getProperty($propName) : string

Static

System properties are "global" properties like application.startdir, and user.dir. Many of these correspond to similar properties in Java or Ant.

### Parameters

#### $propName

### Returns

`string`Value of found property (or null, if none found).

## Looks on include path for specified file.

    getResourcePath($path) : string

Static

### Parameters

#### $path

### Returns

`string`File found (null if no file found).

## Returns reference to Timer object.

    getTimer() : \Timer

Static

### Returns

`\Timer`

## Halts the system.

    halt()

Static

deprecated | This method is deprecated and is no longer called by Phing internally. Any normal shutdown routines are handled by the shutdown() method.
see | \global\shutdown()

## Error handler for PHP errors encountered during the build.

    handlePhpError($level, $message, $file, $line)

Static

This uses the logging for the currently configured project.

### Parameters

#### $level

#### $message

#### $file

#### $line

## Import a dot-path notation class path.

    import(string $dotPath, mixed $classpath) : string

Static

### Parameters

#### $dotPath

`string`

#### $classpath

`mixed`

String or object supporting __toString()

### Exceptions

`\BuildException` | - if cannot find the specified file

### Returns

`string`The unqualified classname (which can be instantiated).

## A static convenience method to send a log to the current (last-setup) Project.

    log(string $message, int $priority)

Static

If there is no currently-configured Project, then this will do nothing.

### Parameters

#### $message

`string`

#### $priority

`int`

Project::MSG_INFO, etc.

## Print the project description, if any

    printDescription(\Project $project)

Static

### Parameters

#### $project

## Prints the message of the Exception if it's not null.

    printMessage(\Exception $t)

Static

### Parameters

#### $t

`\Exception`

## Print out a list of all targets in the current buildfile

    printTargets($project)

### Parameters

#### $project

## Prints the usage of how to use this class

    printUsage()

Static

## Prints the current Phing version.

    printVersion()

Static

## Executes the build.

    runBuild() : void

## Sets the current Project

    setCurrentProject(\Project $p)

Static

### Parameters

#### $p

`\Project`

## This sets a property that was set via command line or otherwise passed into Phing.

    setDefinedProperty(string $name, $value) : string

Static

### Parameters

#### $name

`string`

#### $value

### Returns

`string`value of found property (or null, if none found).

## Sets the stream to use for error output.

    setErrorStream(\OutputStream $stream)

Static

### Parameters

#### $stream

`\OutputStream`

The stream to use for error output.

## Sets the stream to use for standard (non-error) output.

    setOutputStream(\OutputStream $stream)

Static

### Parameters

#### $stream

`\OutputStream`

The stream to use for standard output.

## setProperty()

    setProperty($propName, $propValue)

Static

### Parameters

#### $propName

#### $propValue

## Performs any shutdown routines, such as stopping timers.

    shutdown() : void

Static

## Entry point allowing for more options from other front ends.

    start(array $args, array $additionalUserProperties)

Static

This method encapsulates the complete build lifecycle.

see | \global\execute()
see | \global\runBuild()

### Parameters

#### $args

`array`

The commandline args passed to phing shell script.

#### $additionalUserProperties

`array`

Any additional properties to be passed to Phing (alternative front-end might implement this). These additional properties will be available using the getDefinedProperty() method and will be added to the project's "user" properties

### Exceptions

`\Exception` | - if there is an error during build

## Begins capturing PHP errors to a buffer.

    startPhpErrorCapture()

Static

While errors are being captured, they are not logged.

## Start up Phing.

    startup() : void

Static

Sets up the Phing environment but does not initiate the build process.

### Exceptions

`\Exception` | - If the Phing environment cannot be initialized.

## Stops capturing PHP errors to a buffer.

    stopPhpErrorCapture()

Static

The errors will once again be logged after calling this method.

## Unsets the current Project

    unsetCurrentProject()

Static

## Search parent directories for the build file.

    _findBuildFile(string $start, string $suffix) : \PhingFile

Takes the given target as a suffix to append to each parent directory in search of a build file. Once the root of the file-system has been reached an exception is thrown.

### Parameters

#### $start

`string`

Start file path.

#### $suffix

`string`

Suffix filename to look for in parents.

### Exceptions

`\BuildException` | Failed to locate a build file

### Returns

`\PhingFile`A handle to the build file

## Helper to get the parent file for a given file.

    _getParentFile(\PhingFile $file) : \PhingFile

### Parameters

#### $file

`\PhingFile`

### Returns

`\PhingFile`Parent file or null if none

## Writes a formatted list of target names with an optional description.

    _printTargets(array $names, array $descriptions, string $heading, int $maxlen)

### Parameters

#### $names

`array`

The names to be printed. Must not be `null`.

#### $descriptions

`array`

The associated target descriptions. May be `null`, in which case no descriptions are displayed. If non-`null`, this should have as many elements as `names`.

#### $heading

`string`

The heading to display. Should not be `null`.

#### $maxlen

`int`

The maximum length of the names of the targets. If descriptions are given, they are padded to this position so they line up (so long as the names really are shorter than this).

## Bind any registered build listeners to this project.

    addBuildListeners(\Project $project) : void

This means adding the logger and any build listeners that were specified with -listener arg.

### Parameters

#### $project

`\Project`

## Creates the InputHandler and adds it to the project.

    addInputHandler(\Project $project)

### Parameters

#### $project

`\Project`

the project instance.

### Exceptions

`\BuildException` | if a specified InputHandler class could not be loaded.

## comparePhingVersion()

    comparePhingVersion($version)

### Parameters

#### $version

## Converts shorthand notation values as returned by ini_get()

    convertShorthand(string $val)

Static

see | \global\http://www.php.net/ini_get

### Parameters

#### $val

`string`

## Creates the default build logger for sending build events to the log.

    createLogger() : \BuildLogger

### Returns

`\BuildLogger`The created Logger

## Close logfiles, if we have been writing to them.

    handleLogfile()

Static

since | Phing 2.3.0

## Sets the stdout and stderr streams if they are not already set.

    initializeOutputStreams()

Static

## Restores [most] PHP INI values to their pre-Phing state.

    restoreIni() : void

Static

Currently the following settings are not restored: - max_execution_time (because getting current time limit is not possible) - memory_limit (which may have been increased by Phing)

## Sets the include path to PHP_CLASSPATH constant (if this has been defined).

    setIncludePaths() : void

Static

### Exceptions

`\ConfigurationException` | - if the include_path could not be set (for some bizarre reason)

## Sets PHP INI values that Phing needs.

    setIni() : void

Static

## Set System constants which can be retrieved by calling Phing::getProperty($propName).

    setSystemConstants() : void

Static

### Properties

##

    $buildFile

##

    $capturedPhpErrors

##

    $currentProject

##

    $definedProps : \Properties

## Stream for error output.

    $err : \OutputStream

##

    $importPaths

##

    $inputHandlerClassname

## Whether we are using a logfile.

    $isLogFileUsed : boolean

##

    $listeners

##

    $loggerClassname

##

    $msgOutputLevel

Follows Project::MSG_XXX

##

    $origIniSettings : array

see | \global\restoreIni()

## Stream for standard output.

    $out : \OUtputStream

##

    $phpErrorCapture

##

    $projectHelp

##

    $properties

##

    $readyToRun

##

    $targets

##

    $timer

### Constants

## The default build file name

    DEFAULT_BUILD_FILENAME