mini\Util\PathsRegistry class

Documentation

Registry for managing multiple paths with priority-based file resolution

The primary path is always checked first, followed by fallback paths in reverse order of addition (most recently added fallback takes precedence over earlier fallbacks).

This design works naturally with Composer's dependency graph loading order:

  • Dependencies load first (e.g., fubber/mini)
  • Then packages that depend on them (e.g., fubber/some-bundle)
  • Finally the application itself

When each loads and calls addPath(), the most recent (application) will be checked before earlier ones (bundle before framework), allowing natural override cascading.

Example:

$registry = new PathsRegistry('/app/resources');      // Primary path (app)
$registry->addPath('/vendor/mini/resources');         // Framework fallback
$registry->addPath('/vendor/some-bundle/resources');  // Bundle fallback

// Resolution order: /app/resources → /vendor/some-bundle/resources → /vendor/mini/resources
// App overrides bundle, bundle overrides framework

Results are cached per filename until addPath() is called again.

Properties (5)

private string $primaryPath
private array $fallbackPaths
private array $cacheFirst
private array $cacheAll
private string $cachePrefix

Methods (6)

Create a new paths registry with a primary path

Update cache prefix after paths change

Add a fallback path

Find the first occurrence of a file across all paths

Find all occurrences of a file across all paths

Get all registered paths in resolution order

Source

src/Util/PathsRegistry.php:31-192