Download the PHP package caue-santos/auto-class-discovery without Composer

On this page you can find all versions of the php package caue-santos/auto-class-discovery. 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 auto-class-discovery

Auto Class Discovery

GitHub Workflow Status Packagist Packagist Packagist

Scan a directory and get back every class, interface, trait and enum declared in it — along with its parents, implemented interfaces, used traits and PHP attributes — without writing any manual ReflectionClass code.

Typical uses: auto-binding repository implementations to their contracts, auto-registering event listeners/jobs tagged with an attribute, building a plugin system, or asserting architectural rules in your test suite ("every class in App\Models must extend Model").

Features

Requirements

Installation

The service provider is auto-discovered by Laravel. To publish the config file:

Quick start

Or work through the query helpers instead of the raw tree — this is the recommended way to consume the results:

Every one of the helpers above returns an Illuminate\Support\Collection<int, ClassDefinition>, so the usual collection methods (map, filter, sortBy, ...) are available.

The ClassDefinition object

Each discovered symbol is described by a CaueSantos\AutoClassDiscovery\Support\ClassDefinition:

Plus helper methods:

ClassDefinition also implements ArrayAccess, mirroring the shape PHP's own class_implements()/class_parents()/class_uses() return (a name => name map) under the interfaces, parents/parent and traits keys — so $definition['interfaces'] keeps working if you're used to that shape.

Grouping discovery paths

Pass an associative array to scan several directories while keeping their results apart:

Every query helper (classes(), interfaces(), traits(), enums(), ofType(), all(), implementing(), extending(), using(), withAttribute()) accepts an optional $group argument.

Manual registration

Register a class you already know about — say, one shipped by another package — without scanning the filesystem for it. Its kind (class/interface/trait/enum) is detected automatically:

An InvalidDiscoveryTypeException is thrown if the class/interface/trait/enum doesn't actually exist (typo, missing use, etc).

Caching

Scanning the filesystem on every request is wasteful in production. Configure your discovery paths once in config/auto-class-discovery.php:

then either run the artisan command as part of your deploy step (alongside config:cache/route:cache):

or let the package cache itself lazily on first use:

discoverOrCache() reads the cache file when it exists and only touches the filesystem otherwise, writing the cache right after. Lower-level building blocks are also available: cache(string $path), loadFromCache(string $path): bool, clearCache(string $path).

Real-world recipes

Auto-bind repository implementations to their contracts

Given a convention where every class under App\Repositories implements exactly one repository contract:

Auto-register event listeners tagged with an attribute

Assert architectural conventions in a test

Testing

Upgrading to 1.0

1.0 is a rewrite of the pre-1.0 dev-master version and includes breaking changes — see CHANGELOG.md for the full list:

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits


All versions of auto-class-discovery with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/filesystem Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.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 caue-santos/auto-class-discovery contains the following files

Loading the files please wait ...