mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 10:02:02 -04:00
Add Composer autoloading functions and PHPStan for testing
This commit is contained in:
parent
e198c4db65
commit
f5d7d4e02a
1518 changed files with 169063 additions and 30 deletions
78
vendor/nette/robot-loader/readme.md
vendored
Normal file
78
vendor/nette/robot-loader/readme.md
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
RobotLoader: comfortable autoloading
|
||||
====================================
|
||||
|
||||
[](https://packagist.org/packages/nette/robot-loader)
|
||||
[](https://travis-ci.org/nette/robot-loader)
|
||||
[](https://coveralls.io/github/nette/robot-loader?branch=master)
|
||||
[](https://github.com/nette/robot-loader/releases)
|
||||
[](https://github.com/nette/robot-loader/blob/master/license.md)
|
||||
|
||||
|
||||
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
|
||||
|
||||
RobotLoader is extremely comfortable and addictive!
|
||||
|
||||
If you like Nette, **[please make a donation now](https://nette.org/donate)**. Thank you!
|
||||
|
||||
So we can forget about those famous code blocks:
|
||||
|
||||
```php
|
||||
require_once 'Utils/Page.php';
|
||||
require_once 'Utils/Style.php';
|
||||
require_once 'Utils/Paginator.php';
|
||||
...
|
||||
```
|
||||
|
||||
Like the Google robot crawls and indexes websites, RobotLoader crawls all PHP scripts and records what classes and interfaces were found in them.
|
||||
These records are then saved in cache and used during all subsequent requests.
|
||||
|
||||
Documentation can be found on the [website](https://doc.nette.org/robotloader).
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
The recommended way to install is via Composer:
|
||||
|
||||
```
|
||||
composer require nette/robot-loader
|
||||
```
|
||||
|
||||
It requires PHP version 5.6 and supports PHP up to 7.2.
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
You just need to specifiy what directories to index and where to save the cache:
|
||||
|
||||
```php
|
||||
$loader = new Nette\Loaders\RobotLoader;
|
||||
|
||||
// Add directories for RobotLoader to index
|
||||
$loader->addDirectory(__DIR__ . '/app');
|
||||
$loader->addDirectory(__DIR__ . '/libs');
|
||||
|
||||
// And set caching to the 'temp' directory
|
||||
$loader->setTempDirectory(__DIR__ . '/temp');
|
||||
$loader->register(); // Run the RobotLoader
|
||||
```
|
||||
|
||||
And that's all. From now on, you don't need to use `require`. Great, isn't it?
|
||||
|
||||
When RobotLoader encounters duplicate class name during indexing, it throws an exception and informs you about it.
|
||||
|
||||
The `$loader->setAutoRefresh(true or false)` determines whether RobotLoader should reindex files if asked for nonexistent class.
|
||||
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)`.
|
Loading…
Add table
Add a link
Reference in a new issue