switon/dict

Controlled value-set types for actions, validated inputs, and shared option rows for Switon Framework

Maintainers

Package info

github.com/switon-php/dict

Documentation

pkg:composer/switon/dict

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-06 13:43 UTC

This package is auto-updated.

Last update: 2026-06-07 04:07:57 UTC


README

CI PHP 8.3+

Switon's dict boundary for typed action parameters and property values.

Highlights

  • Type-based lookup: each dict class picks its own item set.
  • Input mapping: routed input can become typed dict values.
  • Fallback values: empty input can fall back to the type's default item.
  • Validated values: scalar input can resolve to stored dict values through validation.
  • Framework wiring: validator templates are bundled for app use.

Installation

composer require switon/dict

Quick Start

use Switon\Dict\Dict;
use Switon\Dict\Attribute\DictValue;

final class OrderStatus extends Dict
{
    public static function typeCode(): ?string
    {
        return 'order.status';
    }
}

final class OrderController
{
    public function updateAction(OrderStatus $status): void
    {
        $code = $status->getItemCode();
        $label = $status->getItemName();
        $value = $status->getValue();
    }
}

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

License

MIT.