Download the PHP package open-solid/callable-invoker without Composer
On this page you can find all versions of the php package open-solid/callable-invoker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download open-solid/callable-invoker
More information about open-solid/callable-invoker
Files in open-solid/callable-invoker
Package callable-invoker
Short Description Smart callable execution for PHP
License MIT
Informations about the package callable-invoker
CallableInvoker
A lightweight PHP callable invoker with smart parameter resolution and execution decoration.
Overview
Frameworks often need to execute user-defined callables — controllers, message handlers, console commands, event listeners, or custom entry points — where the arguments are not known at compile time. Each of these requires the same boilerplate: inspect the callable's parameters, resolve their values from some runtime context, and optionally wrap the execution with cross-cutting behavior.
CallableInvoker extracts this pattern into a single reusable component. Instead of duplicating parameter resolution and decoration logic across your framework or application, you delegate it to the invoker and focus on what each callable actually does.
Installation
Usage
The callable invoker accepts any PHP callable — closures, invokable objects, static methods, etc. — and handles the full execution lifecycle:
- Resolve parameters automatically from a context array, default values, or nullability
- Decorate the callable with optional layers (logging, validation, caching, etc.)
- Execute with the resolved arguments and return the result
Documentation
- Automatic Parameter Resolution: Resolves callable parameters from a provided context array, default values, and nullability.
- Execution Decoration: Wraps callables with nested decorators for cross-cutting concerns like logging, validation, caching, or timing. Each decorator can intercept, modify, or short-circuit the execution.
- Grouping: Organizes decorators and resolvers into named groups, allowing different callables to use different sets of decorators and resolvers. Multiple groups can be combined in a single invocation.
- Priority Ordering: Controls the execution order of decorators and resolvers via priority values, ensuring predictable behavior when multiple are registered.
- Support for Any Callable: Works with closures, invokable objects, static methods, named functions, and more.
- Extensibility: Register custom parameter value resolvers (
ParameterValueResolverInterface) and decorators (CallableDecoratorInterface) to extend the invoker's behavior. - Symfony Integration: Ships as a Symfony bundle with autoconfiguration via interfaces and PHP attributes (
#[AsCallableDecorator],#[AsParameterValueResolver]), service tagging, and compiler passes. - Error Handling: Provides specific exceptions for untyped parameters, variadic parameters, unsupported callables, and unresolvable parameters.