Skip to content

Commit 3e8d75d

Browse files
committed
readme: added info about non-autoloading usage
1 parent 591a651 commit 3e8d75d

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

readme.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ Introduction
1414
RobotLoader is a tool that gives you comfort of automated class loading for your entire application including third-party libraries.
1515

1616
- get rid of all `require`
17-
- only necessary scripts are loaded
1817
- requires no strict file naming conventions
1918
- allows more classes in single file
19+
- extremely fast
20+
- no manual cache updates, everything runs automatically
21+
- highly mature, stable and widely used library
2022

21-
RobotLoader is extremely comfortable and addictive!
23+
RobotLoader is incredibly comfortable and addictive!
2224

2325
If you like Nette, **[please make a donation now](https://nette.org/donate)**. Thank you!
2426

@@ -76,3 +78,36 @@ This feature should be disabled on production server.
7678
If you want RobotLoader to skip some directory, use `$loader->excludeDirectory('temp')`.
7779

7880
By default, RobotLoader reports errors in PHP files by throwing exception `ParseError` (since PHP 7.0). It can be disabled via `$loader->reportParseErrors(false)`.
81+
82+
83+
PHP files analyzer
84+
------------------
85+
86+
RobotLoader can also be used to find classes, interfaces, and trait in PHP files without using the autoloading feature:
87+
88+
```php
89+
$loader = new Nette\Loaders\RobotLoader;
90+
$loader->addDirectory(__DIR__ . '/app');
91+
92+
// Scans directories for classes / intefaces / traits
93+
$loader->rebuild();
94+
95+
// Returns array of class => filename pairs
96+
$res = $loader->getIndexedClasses();
97+
```
98+
99+
When scanning files again, we can use the cache and unmodified files will not be analyzed repeatedly:
100+
101+
```php
102+
$loader = new Nette\Loaders\RobotLoader;
103+
$loader->addDirectory(__DIR__ . '/app');
104+
$loader->setTempDirectory(__DIR__ . '/temp');
105+
106+
// Scans directories using a cache
107+
$loader->refresh();
108+
109+
// Returns array of class => filename pairs
110+
$res = $loader->getIndexedClasses();
111+
```
112+
113+
Enjoy RobotLoader!

0 commit comments

Comments
 (0)