PHPackages                             dex/anything - 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. dex/anything

ActiveLibrary

dex/anything
============

It can be anything

1171[2 PRs](https://github.com/edersoares/anything/pulls)PHPCI passing

Since Jul 29Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/edersoares/anything)[ Packagist](https://packagist.org/packages/dex/anything)[ RSS](/packages/dex-anything/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Anything
========

[](#anything)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2379d0fe9781ce60584a8eb884d8660bad70eb09d2b8b5053756d666a95a13d2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465782f616e797468696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dex/anything)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ee59c4c3fcaa8eaf1392f2cdb2bc2f6cef189def7bacab67d13912668a9f7004/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465782f616e797468696e672f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/dex/anything/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/0c0ba9aa66a047b88f9683220afc22b69278ce72ac38ec8efd660ac5c1735976/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465782f616e797468696e672f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/dex/anything/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/d0d0d16dc784e42c8593f66f74473902d3c8a02e6d4f4ae112a21a05d2632075/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465782f616e797468696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dex/anything)

You always need to create auxiliary tables in your database to store few records just to have good database normalization, with `anything` package this will finish.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require dex/anything
```

Now, you can create any virtual/logical model using `Anything` model or extended it.

### Belongs to relation

[](#belongs-to-relation)

Suppose you have a `Person` model that have a `belongsTo` relation with `Gender`, `Race` and `Religion` model, you should have something like this for you models using 4 database tables.

```
class Person extends Model
{
    protected $table = 'person';

    public function gender(): BelongsTo
    {
        return $this->belongsTo(Gender::class);
    }

    public function race(): BelongsTo
    {
        return $this->belongsTo(Race::class);
    }

    public function religion(): BelongsTo
    {
        return $this->belongsTo(Religion::class);
    }
}

class Gender extends Model
{
    protected $table = 'gender';
}

class Race extends Model
{
    protected $table = 'race';
}

class Religion extends Model
{
    protected $table = 'religion';
}
```

For each model you will have a database table.

But using `Anything` model you will have just 2 database tables.

```
class Person extends Model
{
    protected $table = 'person';

    public function gender(): BelongsTo
    {
        return $this->belongsTo(Gender::class);
    }

    public function race(): BelongsTo
    {
        return $this->belongsTo(Race::class);
    }

    public function religion(): BelongsTo
    {
        return $this->belongsTo(Religion::class);
    }
}

class Gender extends Anything
{
}

class Race extends Anything
{
}

class Religion extends Anything
{
}
```

And you still have access through Eloquent relationships normally

```
$person = Person::factory()->create();

$person->gender->label; // Ex.: Female
$person->race->label; // Ex.: Black
$person->religion->label; // Ex.: Atheist
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Eder Soares](https://github.com/edersoares)
- [Edinei Valdameri](https://github.com/edineivaldameri)
- [Robert Ferraz de Sousa](https://github.com/robertfsousa)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance60

Regular maintenance activity

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 71.9% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/195a30f332e238dc26d226f6f62b40d2fe8b227a89b29465fbe8fd201e45f435?d=identicon)[edersoares](/maintainers/edersoares)

---

Top Contributors

[![edersoares](https://avatars.githubusercontent.com/u/957395?v=4)](https://github.com/edersoares "edersoares (46 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![edineivaldameri](https://avatars.githubusercontent.com/u/99054215?v=4)](https://github.com/edineivaldameri "edineivaldameri (3 commits)")

### Embed Badge

![Health badge](/badges/dex-anything/health.svg)

```
[![Health](https://phpackages.com/badges/dex-anything/health.svg)](https://phpackages.com/packages/dex-anything)
```

PHPackages © 2026

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