switon/invoker

Method invocation orchestration for Switon (standalone)

Maintainers

Package info

github.com/switon-php/invoker

Documentation

pkg:composer/switon/invoker

Statistics

Installs: 33

Dependents: 5

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-05-10 03:07 UTC

This package is auto-updated.

Last update: 2026-05-10 03:12:45 UTC


README

Method invocation orchestration for Switon Framework.

Installation

composer require switon/invoker

Requirements: PHP 8.3+

Quick Start

use ReflectionMethod;
use Switon\Binding\ArgumentsBinderInterface;
use Switon\Core\Attribute\Autowired;
use Switon\Invoking\InvokerInterface;

class Dispatcher
{
    #[Autowired] protected ArgumentsBinderInterface $argumentsBinder;
    #[Autowired] protected InvokerInterface $invoker;

    public function dispatch(object $controller, string $action): mixed
    {
        $method = new ReflectionMethod($controller, $action);
        $arguments = $this->argumentsBinder->resolve($method);

        return $this->invoker->invoke([$controller, $action], $arguments);
    }
}

class PostController
{
    public function showAction(int $id): array
    {
        return ['id' => $id];
    }
}

Docs: https://docs.switon.dev/latest/invoker

This package owns the framework invoker contract: Switon\Invoking\InvokerInterface

Invocation hooks now live in switon/invocation.

License

MIT.