cline/cascade

Multi-source resolution with fallback chains for PHP

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/cline/cascade

1.0.3 2025-12-06 07:25 UTC

This package is auto-updated.

Last update: 2025-12-06 07:35:35 UTC


README

GitHub Workflow Status Latest Version on Packagist Software License Total Downloads

Cascade is a framework-agnostic resolver that fetches values from multiple sources in priority order, returning the first match. Perfect for implementing customer-specific → tenant-specific → platform-default fallback chains.

Think: "Get the FedEx credentials for this customer, falling back to platform defaults if they don't have their own."

Requirements

Requires PHP 8.4+

Installation

composer require cline/cascade

Documentation

Full documentation is available at docs.cline.sh/cascade

Quick Example

use Cline\Cascade\Cascade;
use Cline\Cascade\Source\CallbackSource;

// Build a resolution chain
$cascade = new Cascade();

$cascade->from(new CallbackSource(
    name: 'customer',
    resolver: fn($key, $ctx) => $customerDb->find($ctx['customer_id'], $key),
))
    ->fallbackTo(new CallbackSource(
        name: 'platform',
        resolver: fn($key) => $platformDb->find($key),
    ))
    ->as('credentials');

// Resolve with context
$apiKey = $cascade->using('credentials')
    ->for(['customer_id' => 'cust-123'])
    ->get('fedex-api-key');
// Tries customer source first, falls back to platform if not found

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please use the GitHub security reporting form rather than the issue queue.

Credits

License

The MIT License. Please see License File for more information.