adachsoft / action-contracts
Framework-independent contracts and value objects for configurable PHP actions.
Requires
- php: ^8.3
- adachsoft/reference-contracts: ^0.1
Requires (Dev)
- adachsoft/php-code-style: ^0.7.3
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13.4
- rector/rector: ^2.8
- symplify/phpstan-rules: ^14.19
Suggests
- phpunit/phpunit: Required to run the reusable action run repository contract tests.
Provides
None
Conflicts
None
Replaces
None
README
adachsoft/action-contracts provides framework-independent PHP contracts and value objects for describing configurable actions and their execution. Applications can share a consistent action model without coupling their domain logic to a framework.
Capabilities
- Define action types, parameter schemas, and configured action instances.
- Provide contracts for action type registries, parameter validation, authorization, and handler execution.
- Represent execution context, results, and immutable run history, with in-memory implementations for lightweight integrations and tests.
The package does not execute application-specific behavior. Applications provide adapters for handlers, authorization, validation, and persistence. Actor identities use AdachSoft\ReferenceContracts\PrincipalReference from adachsoft/reference-contracts.
Installation
composer require adachsoft/action-contracts
Requirements
Requires PHP 8.3 or later.
Usage
Create an ActionTypeDefinitionDto to describe an available action and its parameters, then store selected parameter values in an ActionDefinitionDto. Implement the execution and authorization contracts in your application, and register action types through ActionTypeRegistryInterface. See the examples for a type definition and handler implementation.