konekt / xtend
Library to support creating extendable, plugin-aware applications
Installs: 5 636
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
Requires (Dev)
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2024-11-15 14:27:57 UTC
README
Requirements
- PHP 8.2+
Features
- Registries
- Hooks
Installation
You can install the package via composer:
composer require konekt/xtend
Usage
Registries
The following example shows a sample registry that holds reference to various PaymentGateway implementations.
Steps:
- Create a class
- Add the
Registry
interface - Use the
HasRegistry
andRequiresClassOrInterface
traits - Add the
$requiredInterface
static property, and set the interface
final class PaymentGateways implements Registry { use HasRegistry; use RequiresClassOrInterface; private static string $requiredInterface = PaymentGateway::class; }
Having that, other developers can add new payment gateways:
PaymentGateways::add('braintree', BrainTreePaymentGateway::class);