Overview

Namespaces

  • Composer
    • Autoload
  • Illuminate
    • Support
      • Contracts
      • Facades
  • Laravella
    • Crud
      • Exceptions
      • Facades
  • None
  • PHP

Classes

  • ClassLoader
  • Overview
  • Namespace
  • Class
  • Tree

Class ClassLoader

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.

Namespace: Composer\Autoload
Author: Fabien Potencier <fabien@symfony.com>
Author: Jordi Boggiano <j.boggiano@seld.be>
Located at vendor/composer/ClassLoader.php
Methods summary
public
# getPrefixes( )
public
# getFallbackDirs( )
public
# getClassMap( )
public
# addClassMap( array $classMap )

Parameters

$classMap
array
$classMap Class to filename map
public
# add( string $prefix, array|string $paths, boolean $prepend = false )

Registers a set of classes, merging with any others previously set.

Registers a set of classes, merging with any others previously set.

Parameters

$prefix
string
$prefix The classes prefix
$paths
array|string
$paths The location(s) of the classes
$prepend
boolean
$prepend Prepend the location(s)
public
# set( string $prefix, array|string $paths )

Registers a set of classes, replacing any others previously set.

Registers a set of classes, replacing any others previously set.

Parameters

$prefix
string
$prefix The classes prefix
$paths
array|string
$paths The location(s) of the classes
public
# setUseIncludePath( boolean $useIncludePath )

Turns on searching the include path for class files.

Turns on searching the include path for class files.

Parameters

$useIncludePath
boolean
$useIncludePath
public boolean
# getUseIncludePath( )

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

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

Returns

boolean
public
# register( boolean $prepend = false )

Registers this instance as an autoloader.

Registers this instance as an autoloader.

Parameters

$prepend
boolean
$prepend Whether to prepend the autoloader or not
public
# unregister( )

Unregisters this instance as an autoloader.

Unregisters this instance as an autoloader.

public boolean|null
# loadClass( string $class )

Loads the given class or interface.

Loads the given class or interface.

Parameters

$class
string
$class The name of the class

Returns

boolean|null
True if loaded, null otherwise
public string|false
# findFile( string $class )

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

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

Parameters

$class
string
$class The name of the class

Returns

string|false
The path if found, false otherwise
crud API documentation generated by ApiGen 2.8.0