Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Zend Loader Laravel Package

zendframework/zend-loader

Autoloading and class loading utilities for Zend Framework applications. Provides standard and optimized autoloaders (including PSR-0/PSR-4 style support), plugin class loading, and tools to resolve and map class names to files for legacy or modular codebases.

View on GitHub
Deep Wiki
Context7

The AutoloaderFactory

zend-loader provides multiple autoloader strategies. Zend\Loader\AutoloaderFactory allows you to define configuration for each strategy you wish to use and register them at once. As an example, you may have a class map for your most used classes, but want to use a PSR-0 style autoloader for 3rd party libraries. The factory uses configuration, allowing you to cache your autoloader definitions or define them centrally for your application.

Quick Start

The AutoloaderFactory expects an array of configuration.

$config = [
    'Zend\Loader\ClassMapAutoloader' => [
        'application' => APPLICATION_PATH . '/.classmap.php',
        'zf'          => APPLICATION_PATH . '/../library/Zend/.classmap.php',
    ],
    'Zend\Loader\StandardAutoloader' => [
        'namespaces' => [
            'Phly\Mustache' => APPLICATION_PATH . '/../library/Phly/Mustache',
            'Doctrine'      => APPLICATION_PATH . '/../library/Doctrine',
        ],
    ],
];

Once you have your configuration in a PHP array, pass it to the AutoloaderFactory:

// This example assumes that the AutoloaderFactory is itself autoloadable!
use Zend\Loader\AutoloaderFactory;

AutoloaderFactory::factory($config);

The AutoloaderFactory will instantiate each autoloader with the given options, and also call its register() method to register it with the SPL autoloader.

Configuration options

The AutoloaderFactory expects an associative array or Traversable object. Keys should be valid autoloader class names, and the values should be the options that should be passed to the class constructor.

Internally, the AutoloaderFactory checks to see if the autoloader class referenced exists. If not, it will use the StandardAutoloader to attempt to load the class via the include_path. If the class is not found, or does not implement the SplAutoloader interface, an exception will be raised.

Available methods

factory

static factory(array|Traversable $options) : void

Instantiate and register autoloaders.

This method is static, and is used to instantiate autoloaders and register them with the SPL autoloader. It expects either an array or Traversable object as denoted in the [options section](#configuration options).

getRegisteredAutoloaders

static getRegisteredAutoloaders() : SplAutoloader[]

Retrieve a list of all autoloaders registered using the factory.

This method is static, and may be used to retrieve a list of all autoloaders registered via the factory() method. It returns an array of SplAutoloader instances.

getRegisteredAutoloader

static getRegisteredAutoloader($class) : SplAutoloader

Retrieve an autoloader by class name.

This method is static, and is used to retrieve a specific autoloader by class name. If the autoloader is not registered, an exception will be thrown.

unregisterAutoloaders

static unregisterAutoloaders() : void

Unregister all autoloaders registered via the factory.

This method is static, and can be used to unregister all autoloaders that were registered via the factory. Note that this will not unregister autoloaders that were registered outside of the factory.

unregisterAutoloader

static unregisterAutoloader($class) : bool

Unregister an autoloader registered via the factory.

This method is static, and can be used to unregister an autoloader that was registered via the factory. Note that this will not unregister autoloaders that were registered outside of the factory. If the autoloader is registered via the factory, after unregistering it will return TRUE, otherwise FALSE.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport