RobotLoader
class RobotLoader
Scans directories for PHP classes, interfaces, traits, and enums and autoloads them on demand.
Unlike PSR-4, does not require any naming conventions — classes are discovered by content.
$loader = new Nette\Loaders\RobotLoader;
$loader->addDirectory('app');
$loader->excludeDirectory('app/exclude');
$loader->setCacheDirectory('temp');
$loader->register(); Constants
| private RetryLimit |
|
Properties
| list<string> | $ignoreDirs | ||
| list<string> | $acceptFiles |
Methods
No description
Saves the cache if it was modified during the request.
Registers the autoloader via spl_autoload_register().
Autoloads the requested class, interface, trait, or enum.
Adds one or more directories (or individual files) to scan for classes.
Controls whether PHP parse errors in scanned files are rethrown. Enabled by default.
Excludes one or more directories (or individual files) from scanning.
Returns all indexed classes with their file paths.
Rebuilds the class index from scratch, discarding any previously cached data.
Loads the cached index and incrementally updates it for any changed files.
Enables or disables automatic cache refresh on every autoload attempt. Enabled by default.
Sets the directory for storing the class index cache. Must be an absolute path.
No description
Details
at line 60
__construct()
No description
at line 71
__destruct()
Saves the cache if it was modified during the request.
at line 83
RobotLoader
register(bool $prepend = false)
Registers the autoloader via spl_autoload_register().
at line 93
void
tryLoad(string $type)
Autoloads the requested class, interface, trait, or enum.
at line 135
RobotLoader
addDirectory(string ...$paths)
Adds one or more directories (or individual files) to scan for classes.
at line 145
RobotLoader
reportParseErrors(bool $state = true)
Controls whether PHP parse errors in scanned files are rethrown. Enabled by default.
at line 155
RobotLoader
excludeDirectory(string ...$paths)
Excludes one or more directories (or individual files) from scanning.
at line 166
array
getIndexedClasses()
Returns all indexed classes with their file paths.
at line 181
void
rebuild()
Rebuilds the class index from scratch, discarding any previously cached data.
at line 195
void
refresh()
Loads the cached index and incrementally updates it for any changed files.
at line 397
RobotLoader
setAutoRefresh(bool $state = true)
Enables or disables automatic cache refresh on every autoload attempt. Enabled by default.
Disable in production for better performance; clear the cache manually on deployment.
at line 407
RobotLoader
setCacheDirectory(string $dir)
Sets the directory for storing the class index cache. Must be an absolute path.
at line 419
RobotLoader
setTempDirectory(string $dir)
deprecated
deprecated
No description
at line 531
protected array
generateCacheKey()
No description