nette/robot-loader
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
nette/utils | v4.0.4 | 61.98 kB | (BSD-3-Clause OR GPL-2.0-only OR GPL-3.0-only) | prod | 1 |
Nette's RobotLoader is a cutting-edge autoloading tool engineered to deliver high performance alongside the comfort of automated class loading for your entire application, including third-party libraries. The significance of RobotLoader is its ability to rid your code of 'require' directives. It does this by taking on the arduous task of identifying, locating, and loading PHP classes on your behalf. This functionality extends even when the code does not follow strict directory or file naming conventions. With a track record for extreme speed and automatic cache updates, RobotLoader is widely recognized as a mature, stable, and sought-after library.
To start using RobotLoader, ensure that you have PHP version 8.0 (or higher) installed. Since the recommended method of installation is via Composer, you first need to require the package by running:
composer require nette/robot-loader
With the package now part of your project, you can make use of RobotLoader by creating a new instance and providing the directories to be indexed as well as the location for cache storage:
$loader = new Nette\Loaders\RobotLoader;
// Include directories to be indexed by RobotLoader (including subdirectories)
$loader->addDirectory(__DIR__ . '/app');
$loader->addDirectory(__DIR__ . '/libs');
// Use 'temp' directory for cache storage
$loader->setTempDirectory(__DIR__ . '/temp');
$loader->register(); // Activate the RobotLoader
This will allow RobotLoader to scan all your PHP scripts and record the classes and interfaces found in them, hence eliminating the necessity of manually using 'require'.
The documentation for Nette's RobotLoader is not provided on the GitHub page. However, you can obtain comprehensive details about using the tool from the Nette Framework's official website. Moreover, the readme file provided in the nette/robot-loader GitHub repository offers significant insights and usage cases into how to effectively implement RobotLoader in your project.