Download the PHP package nette/robot-loader without Composer

On this page you can find all versions of the php package nette/robot-loader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package robot-loader

RobotLoader

Downloads this Month Tests Coverage Status Latest Stable Version License

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
✅ doesn't require strict naming conventions for directories or files
✅ extremely fast
✅ no manual cache updates, everything runs automatically
✅ mature, stable and widely used library

Thus, we can forget about these familiar code blocks:

 <!---->

Support Me

Do you like RobotLoader? Are you looking forward to the new features?

Buy me a coffee

Thank you!

 <!---->

Installation

You can download RobotLoader as a single standalone file RobotLoader.php, which you include using require in your script, and instantly enjoy comfortable autoloading for the entire application.

If you're building an application using Composer, you can install it via:

It requires PHP version 8.0 and supports PHP up to 8.4.

 <!---->

Usage

Similar to how the Google robot crawls and indexes web pages, the RobotLoader goes through all PHP scripts and notes which classes, interfaces, traits and enums it found. It then stores the results in cache for use in subsequent requests. You just need to specify which directories it should go through and where to store the cache:

And that's it, from this point on, we don't need to use require. Awesome!

If RobotLoader encounters a duplicate class name during indexing, it will throw an exception and notify you. RobotLoader also automatically updates the cache when it needs to load an unknown class. We recommend turning this off on production servers, see [#Caching].

If you want RobotLoader to skip certain directories, use $loader->excludeDirectory('temp') (can be called multiple times or pass multiple directories).

By default, RobotLoader reports errors in PHP files by throwing a ParseError exception. This can be suppressed using $loader->reportParseErrors(false).

 <!---->

PHP Files Analyzer

RobotLoader can also be used purely for finding classes, interfaces, traits and enums in PHP files without using the autoloading function:

Even with such usage, you can utilize caching. This ensures that unchanged files won't be rescanned:

 <!---->

Caching

RobotLoader is very fast because it cleverly uses caching.

During development, you hardly notice it running in the background. It continuously updates its cache, considering that classes and files can be created, deleted, renamed, etc. And it doesn't rescan unchanged files.

On a production server, on the other hand, we recommend turning off cache updates using $loader->setAutoRefresh(false) (in a Nette Application, this happens automatically), because files don't change. At the same time, it's necessary to clear the cache when uploading a new version to hosting.

The initial file scanning, when the cache doesn't exist yet, can naturally take a moment for larger applications. RobotLoader has built-in prevention against cache stampede. This is a situation where a large number of concurrent requests on a production server would trigger RobotLoader, and since the cache doesn't exist yet, they would all start scanning files, which would overload the server. Fortunately, RobotLoader works in such a way that only the first thread indexes the files, creates the cache, and the rest wait and then use the cache.

 <!---->

PSR-4

Nowadays, you can use Composer for autoloading while adhering to PSR-4. Simply put, it's a system where namespaces and class names correspond to the directory structure and file names, e.g., App\Router\RouterFactory will be in the file /path/to/App/Router/RouterFactory.php.

RobotLoader isn't tied to any fixed structure, so it's useful in situations where you don't want to have the directory structure designed exactly like the PHP namespaces, or when developing an application that historically doesn't use such conventions. It's also possible to use both loaders together.

If you like RobotLoader, please make a donation now. Thank you!


All versions of robot-loader with dependencies

PHP Build Version
Package Version
Requires php Version 8.0 - 8.4
ext-tokenizer Version *
nette/utils Version ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nette/robot-loader contains the following files

Loading the files please wait ....