Documentation

目次

前のトピックへ

< Class Phalcon\Kernel

次のトピックへ

Class Phalcon\Loader\Exception >

このページ

Class Phalcon\Loader

implements Phalcon\Events\EventsAwareInterface

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

<?php

 //Creates the autoloader
 $loader = new Phalcon\Loader();

 //Register some namespaces
 $loader->registerNamespaces(array(
   'Example\Base' => 'vendor/example/base/',
   'Example\Adapter' => 'vendor/example/adapter/',
   'Example' => 'vendor/example/'
 ));

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

 //Requiring this class will automatically include file vendor/example/adapter/Some.php
 $adapter = Example\Adapter\Some();

Methods

public __construct ()

Phalcon\Loader constructor

public setEventsManager (Phalcon\Events\ManagerInterface $eventsManager)

Sets the events manager

public Phalcon\Events\ManagerInterface getEventsManager ()

Returns the internal event manager

public Phalcon\Loader setExtensions (array $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 (array $namespaces, [boolean $merge])

Register namespaces and their related directories

public array getNamespaces ()

Return current namespaces registered in the autoloader

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

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

public getPrefixes ()

Return current prefixes registered in the autoloader

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

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

public getDirs ()

Return current directories registered in the autoloader

public Phalcon\Loader registerClasses (array $classes, [boolean $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 (string $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