Class Phalcon\Loader

implements Phalcon\Events\EventsAwareInterface

This component helps to load your project classes automatically based on some conventions

  1. <?php
  2. //Creates the autoloader
  3. $loader = new Loader();
  4. //Register some namespaces
  5. $loader->registerNamespaces(array(
  6. 'Example\Base' => 'vendor/example/base/',
  7. 'Example\Adapter' => 'vendor/example/adapter/',
  8. 'Example' => 'vendor/example/'
  9. ));
  10. //register autoloader
  11. $loader->register();
  12. //Requiring this class will automatically include file vendor/example/adapter/Some.php
  13. $adapter = Example\Adapter\Some();

Methods

public __construct ()

Phalcon\Loader constructor

public setEventsManager (unknown $eventsManager)

Sets the events manager

public Phalcon\Events\ManagerInterface getEventsManager ()

Returns the internal event manager

public Phalcon\Loader setExtensions (unknown $extensions)

Sets an array of extensions that the loader must try in each attempt to locate the file

public boolean getExtensions ()

Return file extensions registered in the loader

public Phalcon\Loader registerNamespaces (unknown $namespaces, [unknown $merge])

Register namespaces and their related directories

public getNamespaces ()

Return current namespaces registered in the autoloader

public Phalcon\Loader registerPrefixes (unknown $prefixes, [unknown $merge])

Register directories on which “not found” classes could be found

public getPrefixes ()

Return current prefixes registered in the autoloader

public Phalcon\Loader registerDirs (unknown $directories, [unknown $merge])

Register directories on which “not found” classes could be found

public getDirs ()

Return current directories registered in the autoloader

public Phalcon\Loader registerClasses (unknown $classes, [unknown $merge])

Register classes and their locations

public getClasses ()

Return the current class-map registered in the autoloader

public Phalcon\Loader register ()

Register the autoload method

public Phalcon\Loader unregister ()

Unregister the autoload method

public boolean autoLoad (unknown $className)

Makes the work of autoload registered classes

public string getFoundPath ()

Get the path when a class was found

public string getCheckedPath ()

Get the path the loader is checking for a path