PHPackages                             synortix/laravel-dictionary - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. synortix/laravel-dictionary

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

synortix/laravel-dictionary
===========================

Laravel API dictionary support and validation library. Humanize your Enum's in API resource responses.

1.0.1(6y ago)02.1kMITPHPPHP ^7.0CI failing

Since Jan 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/synortix/laravel-dictionary)[ Packagist](https://packagist.org/packages/synortix/laravel-dictionary)[ RSS](/packages/synortix-laravel-dictionary/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Laravel Humanized Dictionary Enum
=================================

[](#laravel-humanized-dictionary-enum)

Laravel API enum dictionary support and validation library.

Humanize your Enum's in API resource responses.

Installing
----------

[](#installing)

### Composer

[](#composer)

To get started install package by requiring it through composer CLI

```
composer require synortix/laravel-dictionary:1.*

```

Usage
-----

[](#usage)

### Define Dictionary

[](#define-dictionary)

You can define your dictionary by extending **Synortix\\Dictionary\\Dictionary** class

```
    use Synortix\Dictionary\Dictionary;

    class CustomerTypeDictionary extends Dictionary
    {
        const FREE = 1;
        const PAID = 2;
    }

```

### Create Dictionary Instance

[](#create-dictionary-instance)

You can create object from string representation and pass that further as object. *Dictionary string case-insensitive*.

```
    try {
        $customerType = new CustomerTypeDictionary($request->get('customer_type'));
    } catch (UnexpectedValueException $e) {
        // invalid value, handle it here
    }

```

### Use in Model Resources

[](#use-in-model-resources)

```
    class CustomerResource extends Resource
    {
        public function toArray($request)
        {
            return [
                'id' => $this->resource->id,
                'type' => (string) new CustomerTypeDictionary($this->resource->type)
            ];
        }
    }

```

### Validate request parameter

[](#validate-request-parameter)

```

    $this->validate($request, [
        'cusomer_type' => ['required', new DictionaryRule(CustomerTypeDictionary::class)],
    ]);

```

Running the tests
-----------------

[](#running-the-tests)

For testing purposes this library use PHPUnit. To run tests on your own execute the following command.

```
clone git@github.com:synortix/laravel-dictionary.git
cd laravel-dictionary
composer install
php vendor/bin/phpunit --bootstrap vendor/autoload.php tests/

```

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~264 days

Total

2

Last Release

2458d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44495512?v=4)[Synortix](/maintainers/synortix)[@synortix](https://github.com/synortix)

---

Top Contributors

[![yhortuk](https://avatars.githubusercontent.com/u/17699384?v=4)](https://github.com/yhortuk "yhortuk (4 commits)")[![DevYK](https://avatars.githubusercontent.com/u/72310334?v=4)](https://github.com/DevYK "DevYK (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/synortix-laravel-dictionary/health.svg)

```
[![Health](https://phpackages.com/badges/synortix-laravel-dictionary/health.svg)](https://phpackages.com/packages/synortix-laravel-dictionary)
```

###  Alternatives

[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135212.4k7](/packages/statamic-rad-pack-runway)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21313.7k3](/packages/ecotone-laravel)[carsdotcom/laravel-json-schema

Json Schema validation for Laravel projects

1040.9k5](/packages/carsdotcom-laravel-json-schema)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3310.1k](/packages/duncanmcclean-statamic-cargo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
