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();
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)
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();
initialize() : \phpDocumentor\Application
Convenience method that does the complete initialization for phpDocumentor.
createAutoloader(string|null $vendorDir = null) : \Composer\Autoload\ClassLoader
Initializes and returns the autoloader.
string|null | $vendorDir | A path (either absolute or relative to the current working directory) leading to the vendor folder where composer installed the dependencies. |
if no autoloader could be found.
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.
$baseDir | parameter for test purposes only. |