Skip to content

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.

License

Notifications You must be signed in to change notification settings

faustbrian/cascade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

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.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages