P4PHP Classes
The P4 module consists of several public classes:
- P4
- P4_Exception
- P4_DepotFile
- P4_Revision
- P4_Integration
- P4_Map
- P4_MergeData
- P4_OutputHandlerAbstract
- P4_Resolver
The following tables provide more details about each public class.
P4
Helix Core Server client class. Handles connection and interaction with the Helix Core Server. There is one instance of each connection.
The following table lists properties of the class P4
in
P4PHP. The properties
are readable and writable unless indicated otherwise. The properties can
be strings, arrays, or integers.
Property | Description |
---|---|
API compatibility level. (Lock server output to a specified server level.) |
|
Charset for Unicode servers. |
|
|
|
Current working directory. |
|
A read-only array containing the error messages received during execution of the last command. |
|
The exception level of the P4 instance. Values can be:
The default value is 2. |
|
Control whether keys with trailing numbers are expanded into arrays; by default, true, for backward-compatibility. |
|
An output handler. |
|
|
|
Input for the next command. Can be a string, or an array. |
|
MaxLockTime used for all following commands. |
|
MaxResults used for all following commands. |
|
MaxScanRows used for all following commands. |
|
The location of the configuration file used
( |
|
|
|
|
|
The name of the script. |
|
Returns the current Helix Core Server level. This property is read only. |
|
Enable or disable support for streams. |
|
To disable tagged output for the following commands, set the value to 0 or False. By default, tagged output is enabled. |
|
|
|
|
|
The version of the script. |
|
A read-only array containing the warning messages received during execution of the last command. |
The following table lists all public methods of the class
P4
.
Method | Description |
---|---|
Connects to the Helix Core Server. |
|
Returns |
|
Deletes the spec <spectype>. Equivalent to the command:
P4::run( "<spectype>", "-d" );
|
|
Disconnects from the Helix Core Server. |
|
Get the value of a
Helix Core Server
environment variable, taking into account |
|
Returns a string identifying the P4PHP module. (This method is static.) |
|
Fetches the spec <spectype>. Equivalent to the command:
P4::run( "<spectype>", "-o" );
|
|
Converts the spec <spectype> into a string. |
|
Parses a string representation of the spec <spectype> and returns an array. |
|
Runs a command on the server. Needs to be connected, or an exception is raised. |
|
Runs the command cmd. Equivalent to:
P4::run( "cmd" );
|
|
This command returns an array of
|
|
Logs in using the specified password or ticket. |
|
Convenience method: updates the password. Takes two arguments: oldpassword, newpassword. |
|
Interface to |
|
Convenience method for submitting changelists. When invoked with a change spec, it submits the spec. Equivalent to:
p4::input = myspec;
p4::run( "submit", "-i" );
|
|
Saves the spec <spectype>. Equivalent to the command:
P4::run( "<spectype>", "-i" );
|
P4_Exception
Exception class. Instances of this class are raised when errors and/or
(depending on the exception_level
setting) warnings
are returned by the server. The exception contains the errors in the form
of a string. P4_Exception
extends the standard PHP
Exception
class.
P4_DepotFile
Container class returned by P4::run_filelog()
. Contains the
name of the depot file and an array of P4_Revision
objects.
Property | Description |
---|---|
Name of the depot file |
|
Array of Revision objects. |
P4_Revision
Container class containing one revision of a
P4_DepotFile
object.
Property | Description |
---|---|
Action that created the revision. |
|
Changelist number. |
|
Client workspace used to create this revision. |
|
Short changelist description. |
|
The name of the file in the depot. |
|
MD5 digest of the revision. |
|
File size of this revision. |
|
Array of |
|
Revision. |
|
Timestamp. |
|
File type. |
|
User that created this revision. |
P4_Integration
Container class containing one integration for a
P4_Revision
object.
Property | Description |
---|---|
Integration method (merge/branch/copy/ignored). |
|
Integrated file. |
|
Start revision. |
|
End revision. |
P4_Map
A class that allows users to create and work with Helix Core Server mappings without requiring a connection to the Helix Core Server.
Method | Description |
---|---|
Construct a new Map object. |
|
Joins two maps to create a third (static method). |
|
Empties a map. |
|
Returns the number of entries in a map. |
|
Tests whether or not a map object is empty. |
|
Inserts an entry into the map. |
|
Translate a string through a map. |
|
Tests whether a path is mapped. |
|
Returns a new mapping with the left and right sides reversed. |
|
Returns the left side as an array. |
|
Returns the right side as an array. |
|
Returns the map as an array. |
P4_MergeData
Class encapsulating the context of an individual merge during execution
of a p4 resolve
command. Passed to
P4::run_resolve()
.
Property | Description |
---|---|
Returns the name of "your" file in the merge. (file in workspace) |
|
Returns the name of "their" file in the merge. (file in the depot) |
|
Returns the name of "base" file in the merge. (file in the depot) |
|
Returns the path of "your" file in the merge. (file in workspace) |
|
Returns the path of "their" file in the merge. (temporary file
on workstation into which |
|
Returns the path of the base file in the merge. (temporary file
on workstation into which |
|
Returns the path to the merge result. (temporary file on workstation into which the automatic merge performed by the server has been loaded.) |
|
Returns hint from server as to how user might best resolve merge. |
P4_OutputHandlerAbstract
Handler class that provides access to streaming output from the server;
set $p4->handler
to an instance of a subclass of
P4_OutputHandlerAbstract
to enable callbacks:
Method | Description |
---|---|
Process binary data. |
|
Process tabular data. |
|
Process information or errors. |
|
Process tagged output. |
|
Process text data. |
P4_Resolver
Abstract class for handling resolves in Perforce. This class must be subclassed in order to be used.
Method | Description |
---|---|
Perform a resolve and return the resolve decision as a string. |