Download the PHP package actra/autoloader without Composer
On this page you can find all versions of the php package actra/autoloader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download actra/autoloader
More information about actra/autoloader
Files in actra/autoloader
Package autoloader
Short Description A simple, lightweight, and efficient PHP Autoloader supporting PSR-4, PSR-0, and filesystem caching with OPcache support.
License MIT
Informations about the package autoloader
PHP Autoloader
A simple, lightweight, and efficient PHP Autoloader that supports PSR-4, PSR-0, filesystem caching, and custom file suffix lists. This autoloader is designed to be easy to integrate into any PHP project without the overhead of complex dependency management if you need a standalone solution.
Features
- PSR-4 and PSR-0 Support: Load classes according to modern and legacy standards.
- Filesystem Caching: Boost performance by caching class-to-file mappings in a PHP file.
- Custom Suffixes: Supports multiple file extensions (e.g.,
.php,.inc.php,.class.php). - Namespace Prefixes: Easily map namespaces or prefixes to specific directories.
- Lightweight: Zero external dependencies.
Installation
Via Composer (Recommended)
To install the autoloader via Composer, run:
Standalone (Manual)
If you're not using Composer, simply include the source files in your project:
Basic Usage
PSR-4 Autoloading
PSR-0 Autoloading (Legacy)
Advanced Features
Filesystem Caching
By default, the autoloader uses a local cache file at src/cache/autoloader.php. This significantly speeds up class loading in production environments by leveraging OPcache. The cache directory is automatically created if it doesn't exist.
To use a custom cache location, provide a path when registering:
The cache is automatically updated and saved when the script finishes execution (using a destructor).
Custom File Suffixes
If your project uses non-standard file extensions, you can specify them in the AutoloaderPath constructor:
Requirements
- PHP 8.2 or higher (Uses
readonlyclasses and enums)
License
This project is licensed under the MIT License - see the LICENSE file for details.
© Actra AG - https://www.actra.ch