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."
Requires PHP 8.4+
composer require cline/cascadeFull documentation is available at docs.cline.sh/cascade
- Getting Started - Installation and core concepts
- Basic Usage - Simple examples and patterns
- Conductors - Fluent API for building resolution chains
- Sources - Built-in and custom source types
- Named Resolvers - Managing multiple configurations
- Events - Monitoring resolution lifecycle
- Cookbook - Real-world patterns and recipes
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 foundPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please use the GitHub security reporting form rather than the issue queue.
The MIT License. Please see License File for more information.