PHP Class Burgomaster, instantanalytics

Mostra file Open project: nystudio107/instantanalytics Class Usage Examples

Public Properties

Property Type Description
$projectRoot Root directory of the project
$stageDir Base staging directory of the project

Public Methods

Method Description
__construct ( string $stageDir, string $projectRoot = null )
__destruct ( ) Cleanup if the last section was not already closed.
createAutoloader ( array $files = [], string $filename = 'autoloader.php' ) Creates a class-map autoloader to the staging directory in a file named autoloader.php
createPhar ( string $dest, string | boolean | null $stub = null, string $autoloaderFilename = 'autoloader.php' ) Creates a phar that automatically registers an autoloader.
createZip ( string $dest ) Creates a zip file containing the staged files of your project.
debug ( string $message ) Prints a debug message to STDERR bound to the current section.
deepCopy ( string $from, string $to ) Copies a file and creates the destination directory if needed.
endSection ( ) Call this method when leaving the last pushed section of the packager.
exec ( string $command ) : string Execute a command and throw an exception if the return code is not 0.
recursiveCopy ( string $sourceDir, string $destDir, array $extensions = ['php'] ) Recursively copy one folder to another.
startSection ( string $section ) Call this method when starting a specific section of the packager.

Private Methods

Method Description
createDirIfNeeded ( $dir )
createStub ( $dest, string $autoloaderFilename = 'autoloader.php' ) : string Creates a default stub for the phar that includeds the generated autoloader.

Method Details

__construct() public method

public __construct ( string $stageDir, string $projectRoot = null )
$stageDir string Staging base directory where your packaging takes place. This folder will be created for you if it does not exist. If it exists, it will be deleted and recreated to start fresh.
$projectRoot string Root directory of the project.

__destruct() public method

Cleanup if the last section was not already closed.
public __destruct ( )

createAutoloader() public method

Creates a class-map autoloader to the staging directory in a file named autoloader.php
public createAutoloader ( array $files = [], string $filename = 'autoloader.php' )
$files array Files to explicitly require in the autoloader. This is similar to Composer's "files" "autoload" section.
$filename string Name of the autoloader file.

createPhar() public method

Call this only after your staging directory is built.
public createPhar ( string $dest, string | boolean | null $stub = null, string $autoloaderFilename = 'autoloader.php' )
$dest string Where to save the file. The basename of the file is also used as the alias name in the phar (e.g., /path/to/guzzle.phar => guzzle.phar).
$stub string | boolean | null The path to the phar stub file. Pass or leave null to automatically have one created for you. Pass false to no use a stub in the generated phar.
$autoloaderFilename string Name of the autolaoder filename.

createZip() public method

Call this only after your staging directory is built.
public createZip ( string $dest )
$dest string Where to save the zip file

debug() public method

Prints a debug message to STDERR bound to the current section.
public debug ( string $message )
$message string Message to echo to STDERR

deepCopy() public method

Copies a file and creates the destination directory if needed.
public deepCopy ( string $from, string $to )
$from string File to copy
$to string Destination to copy the file to, relative to the base staging directory.

endSection() public method

Call this method when leaving the last pushed section of the packager.
public endSection ( )

exec() public method

Execute a command and throw an exception if the return code is not 0.
public exec ( string $command ) : string
$command string Command to execute
return string Returns the output of the command as a string

recursiveCopy() public method

Any LICENSE file is automatically copied.
public recursiveCopy ( string $sourceDir, string $destDir, array $extensions = ['php'] )
$sourceDir string Source directory to copy from
$destDir string Directory to copy the files to that is relative to the the stage base directory.
$extensions array File extensions to copy from the $sourceDir. Defaults to "php" files only (e.g., ['php']).

startSection() public method

This makes the debug messages used in your script more meaningful and adds context when things go wrong. Be sure to call endSection() when you have finished a section of your packaging script.
public startSection ( string $section )
$section string Part of the packager that is running

Property Details

$projectRoot public_oe property

Root directory of the project
public $projectRoot

$stageDir public_oe property

Base staging directory of the project
public $stageDir