Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



third_party/vfsstream/vendor/composer/ClassLoader.php

Table of Contents

\Composer\Autoload\ClassLoader

Package: Default
ClassLoader implements a PSR-0 class loader

See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md

$loader = new \Composer\Autoload\ClassLoader();

// register classes with namespaces
$loader->add('Symfony\Component', __DIR__.'/component');
$loader->add('Symfony',           __DIR__.'/framework');

// activate the autoloader
$loader->register();

// to enable searching the include path (eg. for PEAR packages)
$loader->setUseIncludePath(true);

In this example, if you try to use a class in the Symfony\Component namespace or one of its children (Symfony\Component\Console for instance), the autoloader will first look for the class under the component/ directory, and it will then fallback to the framework/ directory if not found before giving up.

This class is loosely based on the Symfony UniversalClassLoader.

Author
Fabien Potencier
Author
Jordi Boggiano

Methods

method public add (string $prefix, array | string $paths, bool $prepend = false) : void

Registers a set of PSR-0 directories for a given prefix, either appending or prepending to the ones previously set for this prefix.

Parameters
Name Type Description
$prefix string

The prefix

$paths array | string

The PSR-0 root directories

$prepend bool

Whether to prepend the directories

method public addClassMap (array $classMap) : void

Parameters
Name Type Description
$classMap array

Class to filename map

method public addPsr4 (string $prefix, array | string $paths, bool $prepend = false) : void

Registers a set of PSR-4 directories for a given namespace, either appending or prepending to the ones previously set for this namespace.

Parameters
Name Type Description
$prefix string

The prefix/namespace, with trailing '\'

$paths array | string

The PSR-0 base directories

$prepend bool

Whether to prepend the directories

method public findFile (string $class) : string | false

Finds the path to the file where the class is defined.

Parameters
Name Type Description
$class string

The name of the class

Returns
Type Description
string | false The path if found, false otherwise
method public getClassMap () : void

method public getFallbackDirs () : void

method public getFallbackDirsPsr4 () : void

method public getPrefixes () : void

method public getPrefixesPsr4 () : void

method public getUseIncludePath () : bool

Can be used to check if the autoloader uses the include path to check for classes.

Returns
Type Description
bool
method public loadClass (string $class) : bool | null

Loads the given class or interface.

Parameters
Name Type Description
$class string

The name of the class

Returns
Type Description
bool | null True if loaded, null otherwise
method public register (bool $prepend = false) : void

Registers this instance as an autoloader.

Parameters
Name Type Description
$prepend bool

Whether to prepend the autoloader or not

method public set (string $prefix, array | string $paths) : void

Registers a set of PSR-0 directories for a given prefix, replacing any others previously set for this prefix.

Parameters
Name Type Description
$prefix string

The prefix

$paths array | string

The PSR-0 base directories

method public setPsr4 (string $prefix, array | string $paths) : void

Registers a set of PSR-4 directories for a given namespace, replacing any others previously set for this namespace.

Parameters
Name Type Description
$prefix string

The prefix/namespace, with trailing '\'

$paths array | string

The PSR-4 base directories

method public setUseIncludePath (bool $useIncludePath) : void

Turns on searching the include path for class files.

Parameters
Name Type Description
$useIncludePath bool
method public unregister () : void

Unregisters this instance as an autoloader.

Documentation was generated by phpDocumentor 2.0.0a12 .