\phpDocumentorBootstrap

This class provides a bootstrap for all application who wish to interface with phpDocumentor.

The Bootstrapper is responsible for setting up the autoloader, profiling options and application, including dependency injection container.

The simplest usage would be:

$app = Bootstap::createInstance()->initialize();

This will setup the autoloader and application, including Service Container, and return an instance of the application ready to be ran using the run command.

If you need more control you can do some of the steps manually:

$bootstrap = Bootstap::createInstance();
$autoloader = $bootstrap->createAutoloader();
$app = new Application($autoloader)

Summary

Methods
Properties
Constants
createInstance()
initialize()
registerProfiler()
createAutoloader()
findVendorPath()
No public properties found
No constants found
getCustomVendorPathFromComposer()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

createInstance()

createInstance() : \phpDocumentor\Bootstrap

Helper static function to get an instance of this class.

Usually used to do a one-line initialization, such as:

\phpDocumentor\Bootstrap::createInstance()->initialize();

Returns

\phpDocumentor\Bootstrap

initialize()

initialize() : \phpDocumentor\Application

Convenience method that does the complete initialization for phpDocumentor.

Returns

\phpDocumentor\Application

registerProfiler()

registerProfiler() : self

Sets up XHProf so that we can profile phpDocumentor using XHGUI.

Returns

self

createAutoloader()

createAutoloader(string|null  $vendorDir = null) : \Composer\Autoload\ClassLoader

Initializes and returns the autoloader.

Parameters

string|null $vendorDir

A path (either absolute or relative to the current working directory) leading to the vendor folder where composer installed the dependencies.

Throws

\RuntimeException

if no autoloader could be found.

Returns

\Composer\Autoload\ClassLoader

findVendorPath()

findVendorPath(  $baseDir = __DIR__) : string|null

Attempts to find the location of the vendor folder.

This method tries to check for a composer.json in a directory 5 levels below the folder of this Bootstrap file. This is the expected location if phpDocumentor is installed using composer because the current directory for this file is expected to be 'vendor/phpdocumentor/phpdocumentor/src/phpDocumentor'.

If a composer.json is found we will try to extract the vendor folder name using the 'vendor-dir' configuration option of composer or assume it is vendor if that option is not set.

If no custom composer.json can be found, then we assume that the vendor folder is that of phpDocumentor itself, which is ../../vendor starting from this folder.

If neither locations exist, then this method returns null because no vendor path could be found.

Parameters

$baseDir

parameter for test purposes only.

Returns

string|null

getCustomVendorPathFromComposer()

getCustomVendorPathFromComposer(string  $composerConfigurationPath) : string

Retrieves the custom vendor-dir from the given composer.json or returns 'vendor'.

Parameters

string $composerConfigurationPath

the path pointing to the composer.json

Returns

string