PHAR.CREATEDEFAULTSTUB(3) 1 PHAR.CREATEDEFAULTSTUB(3)Phar::createDefaultStub - Create a phar-file format specific stub
SYNOPSIS
finalpublicstatic string Phar::createDefaultStub ([string $indexfile], [string $webindexfile])
DESCRIPTION
This method is intended for creation of phar-file format-specific stubs, and is not intended for use with tar- or zip-based phar archives.
Phar archives contain a bootstrap loader, or stub written in PHP that is executed when the archive is executed in PHP either via include:
<?php
include 'myphar.phar';
?>
php myphar.phar
This method provides a simple and easy method to create a stub that will run a startup file from the phar archive. In addition, different
files can be specified for running the phar archive from the command line versus through a web server. The loader stub also calls
Phar.interceptFileFuncs(3) to allow easy bundling of a PHP application that accesses the file system. If the phar extension is not present,
the loader stub will extract the phar archive to a temporary directory and then operate on the files. A shutdown function erases the tempo-
rary files on exit.
RETURN VALUES
Returns a string containing the contents of a customized bootstrap loader (stub) that allows the created Phar archive to work with or
without the Phar extension enabled.
ERRORS /EXCEPTIONS
Throws UnexpectedValueException if either parameter is longer than 400 bytes.
EXAMPLES
Example #1
A Phar.createDefaultStub(3) example
<?php
try {
$phar = new Phar('myphar.phar');
$phar->setStub($phar->createDefaultStub('cli.php', 'web/index.php'));
} catch (Exception $e) {
// handle errors
}
?>
SEE ALSO Phar.setStub(3), Phar.getStub(3).
PHP Documentation Group PHAR.CREATEDEFAULTSTUB(3)
Check Out this Related Man Page
PHAR(3) 1 PHAR(3)The Phar classINTRODUCTION
The Phar class provides a high-level interface to accessing and creating phar archives.
CLASS SYNOPSIS
Phar
Pharextends
RecursiveDirectoryIteratorCountableArrayAccess
Methods
o public void Phar::addEmptyDir (string $dirname)
o public void Phar::addFile (string $file, [string $localname])
o public void Phar::addFromString (string $localname, string $contents)
o finalpublicstatic string Phar::apiVersion (void )
o public array Phar::buildFromDirectory (string $base_dir, [string $regex])
o public array Phar::buildFromIterator (Iterator $iter, [string $base_directory])
o finalpublicstatic bool Phar::canCompress ([int $type])
o finalpublicstatic bool Phar::canWrite (void )
o public object Phar::compress (int $compression, [string $extension])
o public bool Phar::compressAllFilesBZIP2 (void )
o public bool Phar::compressAllFilesGZ (void )
o public void Phar::compressFiles (int $compression)
o public Phar::__construct (string $fname, [int $flags], [string $alias])
o public PharData Phar::convertToData ([int $format = 9021976], [int $compression = 9021976], [string $extension])
o public Phar Phar::convertToExecutable ([int $format = 9021976], [int $compression = 9021976], [string $extension])
o public bool Phar::copy (string $oldfile, string $newfile)
o public int Phar::count (void )
o finalpublicstatic string Phar::createDefaultStub ([string $indexfile], [string $webindexfile])
o public object Phar::decompress ([string $extension])
o public bool Phar::decompressFiles (void )
o public bool Phar::delMetadata (void )
o public bool Phar::delete (string $entry)
o public bool Phar::extractTo (string $pathto, [string|array $files], [bool $overwrite = false])
o public mixed Phar::getMetadata (void )
o public bool Phar::getModified (void )
o public array Phar::getSignature (void )
o public string Phar::getStub (void )
o finalpublicstatic array Phar::getSupportedCompression (void )
o finalpublicstatic array Phar::getSupportedSignatures (void )
o public string Phar::getVersion (void )
o public bool Phar::hasMetadata (void )
o finalpublicstatic void Phar::interceptFileFuncs (void )
o public bool Phar::isBuffering (void )
o public mixed Phar::isCompressed (void )
o public bool Phar::isFileFormat (int $format)
o finalpublicstatic bool Phar::isValidPharFilename (string $filename, [bool $executable = true])
o public bool Phar::isWritable (void )
o finalpublicstatic bool Phar::loadPhar (string $filename, [string $alias])
o finalpublicstatic bool Phar::mapPhar ([string $alias], [int $dataoffset])
o finalpublicstatic void Phar::mount (string $pharpath, string $externalpath)
o finalpublicstatic void Phar::mungServer (array $munglist)
o public bool Phar::offsetExists (string $offset)
o public int Phar::offsetGet (string $offset)
o public void Phar::offsetSet (string $offset, string $value)
o public bool Phar::offsetUnset (string $offset)
o finalpublicstatic string Phar::running ([bool $retphar = true])
o public bool Phar::setAlias (string $alias)
o public bool Phar::setDefaultStub ([string $index], [string $webindex])
o public void Phar::setMetadata (mixed $metadata)
o public void Phar::setSignatureAlgorithm (int $sigtype, [string $privatekey])
o public bool Phar::setStub (string $stub, [int $len = -1])
o public void Phar::startBuffering (void )
o public void Phar::stopBuffering (void )
o public bool Phar::uncompressAllFiles (void )
o finalpublicstatic bool Phar::unlinkArchive (string $archive)
o finalpublicstatic void Phar::webPhar ([string $alias], [string $index = "index.php"], [string $f404], [array $mimetypes], [callable
$rewrites])
PHP Documentation Group PHAR(3)