Skip to content

Commit

Permalink
readme: added info about non-autoloading usage
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 1, 2019
1 parent 591a651 commit 3e8d75d
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ Introduction
RobotLoader is a tool that gives you comfort of automated class loading for your entire application including third-party libraries.

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

RobotLoader is extremely comfortable and addictive!
RobotLoader is incredibly comfortable and addictive!

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

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

By default, RobotLoader reports errors in PHP files by throwing exception `ParseError` (since PHP 7.0). It can be disabled via `$loader->reportParseErrors(false)`.


PHP files analyzer
------------------

RobotLoader can also be used to find classes, interfaces, and trait in PHP files without using the autoloading feature:

```php
$loader = new Nette\Loaders\RobotLoader;
$loader->addDirectory(__DIR__ . '/app');

// Scans directories for classes / intefaces / traits
$loader->rebuild();

// Returns array of class => filename pairs
$res = $loader->getIndexedClasses();
```

When scanning files again, we can use the cache and unmodified files will not be analyzed repeatedly:

```php
$loader = new Nette\Loaders\RobotLoader;
$loader->addDirectory(__DIR__ . '/app');
$loader->setTempDirectory(__DIR__ . '/temp');

// Scans directories using a cache
$loader->refresh();

// Returns array of class => filename pairs
$res = $loader->getIndexedClasses();
```

Enjoy RobotLoader!

0 comments on commit 3e8d75d

Please sign in to comment.