PHPackages                             wpjscc/annotated - 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. [Database &amp; ORM](/categories/database)
4. /
5. wpjscc/annotated

ActiveLibrary[Database &amp; ORM](/categories/database)

wpjscc/annotated
================

Cycle ORM Annotated Entities generator

4.x-dev(6mo ago)0201MITPHPPHP &gt;=8.1

Since Nov 7Pushed 6mo agoCompare

[ Source](https://github.com/wpjscc/annotated)[ Packagist](https://packagist.org/packages/wpjscc/annotated)[ Docs](https://cycle-orm.dev)[ GitHub Sponsors](https://github.com/sponsors/cycle)[ RSS](/packages/wpjscc-annotated/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelogDependencies (11)Versions (1)Used By (1)

Cycle ORM - Annotated Entities
==============================

[](#cycle-orm---annotated-entities)

[![PHP Version Require](https://camo.githubusercontent.com/fbde73fb09871bb8b1a4c3c0a3ed3e173a0353147a9537957362c263e20be10e/68747470733a2f2f706f7365722e707567782e6f72672f6379636c652f616e6e6f74617465642f726571756972652f706870)](https://packagist.org/packages/cycle/annotated)[![Latest Stable Version](https://camo.githubusercontent.com/42b789248ee9ca9272d70de7f0a9939a9325a01c52213d037ba4c07c6a0c490a/68747470733a2f2f706f7365722e707567782e6f72672f6379636c652f616e6e6f74617465642f762f737461626c65)](https://packagist.org/packages/cycle/annotated)[![phpunit](https://github.com/cycle/annotated/actions/workflows/main.yml/badge.svg)](https://github.com/cycle/annotated/actions)[![psalm](https://github.com/cycle/annotated/actions/workflows/psalm.yml/badge.svg)](https://github.com/cycle/annotated/actions)[![psalm-level](https://camo.githubusercontent.com/68227bc5dccff4498ae60697ef346581f7b7ba5b5d9e821e8175860f6f68067d/68747470733a2f2f73686570686572642e6465762f6769746875622f6379636c652f616e6e6f74617465642f6c6576656c2e737667)](https://shepherd.dev/github/cycle/annotated)[![Codecov](https://camo.githubusercontent.com/7439dc0fc4e72181f3c199ecd6c7bda98f034a3912d53cf8318e094d8f1e6baf/68747470733a2f2f636f6465636f762e696f2f67682f6379636c652f616e6e6f74617465642f6272616e63682f342e782f67726170682f62616467652e737667)](https://codecov.io/gh/cycle/annotated/)[![Total Downloads](https://camo.githubusercontent.com/e32bddf94d700b97e532f04a8dd98de712155746f6006f33a346dda5abeb1531/68747470733a2f2f706f7365722e707567782e6f72672f6379636c652f616e6e6f74617465642f646f776e6c6f616473)](https://packagist.org/packages/cycle/annotated)[![](https://camo.githubusercontent.com/4442b73a11753b80fdd7b442ddbfaf8383902c8b9ffa66ed1718e8c62e102f2e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646973636f72642d636861742d6d6167656e74612e737667)](https://discord.gg/8bZsjYhVVk)

**[Documentation](https://cycle-orm.dev/docs/annotated-prerequisites)** | [Cycle ORM](https://github.com/cycle/orm)

The package provides the ability to define Cycle ORM schema using PHP attributes.

Usage
-----

[](#usage)

```
use Cycle\Annotated\Annotation\Entity;
use Cycle\Annotated\Annotation\Column;

#[Entity]
class User
{
    #[Column(type: 'primary')]
    private int $id;

    #[Column(type: 'string(32)')]
    private string $login;

    #[Column(type: 'enum(active,disabled)')]
    private string $status;

    #[Column(type: 'decimal(5,5)')]
    private $balance;
}
```

### Relations

[](#relations)

#### HasOne

[](#hasone)

```
use Cycle\Annotated\Annotation\Relation\HasOne;
use Cycle\Annotated\Annotation\Entity;

#[Entity]
class User
{
    // ...

    #[HasOne(target: Address::class)]
    public ?Address $address;
}
```

> **Note**Read more about [HasOne](https://cycle-orm.dev/docs/relation-has-one).

#### HasMany

[](#hasmany)

```
use Cycle\Annotated\Annotation\Entity;
use Cycle\Annotated\Annotation\Relation\HasMany;

#[Entity]
class User
{
    // ...

    #[HasMany(target: Post::class)]
    private array $posts;
}
```

> **Note**Read more about [HasMany](https://cycle-orm.dev/docs/relation-has-many).

#### BelongsTo

[](#belongsto)

```
use Cycle\Annotated\Annotation\Entity;
use Cycle\Annotated\Annotation\Relation\BelongsTo;

#[Entity]
class Post
{
    // ...

    #[BelongsTo(target: User::class)]
    private User $user;
}
```

> **Note**Read more about [BelongsTo](https://cycle-orm.dev/docs/relation-belongs-to).

#### RefersTo

[](#refersto)

```
use Cycle\Annotated\Annotation\Entity;
use Cycle\Annotated\Annotation\Relation\RefersTo;
use Cycle\Annotated\Annotation\Relation\HasMany;

#[Entity]
class User
{
    // ...

    #[RefersTo(target: Comment::class)]
    private ?Comment $lastComment;

    #[HasMany(target: Comment::class)]
    public array $comments;

    // ...

    public function addComment(Comment $c): void
    {
        $this->lastComment = $c;
        $this->comments[] = $c;
    }

    public function removeLastComment(): void
    {
        $this->lastComment = null;
    }

    public function getLastComment(): ?Comment
    {
        return $this->lastComment;
    }
}
```

> **Note**Read more about [RefersTo](https://cycle-orm.dev/docs/relation-refers-to).

#### ManyToMany

[](#manytomany)

```
use Cycle\Annotated\Annotation\Relation\ManyToMany;
use Cycle\Annotated\Annotation\Entity;

#[Entity]
class User
{
    // ...

    #[ManyToMany(target: Tag::class, through: UserTag::class)]
    protected array $tags;

    public function getTags(): array
    {
        return $this->tags;
    }

    public function addTag(Tag $tag): void
    {
        $this->tags[] = $tag;
    }

    public function removeTag(Tag $tag): void
    {
        $this->tags = array_filter($this->tags, static fn(Tag $t) => $t !== $tag);
    }
}
```

> **Note**Read more about [ManyToMany](https://cycle-orm.dev/docs/relation-many-to-many).

#### Embedded Entities

[](#embedded-entities)

```
use Cycle\Annotated\Annotation\Embeddable;
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\Annotated\Annotation\Relation\Embedded;

#[Embeddable]
class UserCredentials
{
    #[Column(type: 'string(255)')]
    public string $username;

    #[Column(type: 'string')]
    public string $password;
}

#[Entity]
class User
{
    #[Column(type: 'primary')]
    public int $id;

    #[Embedded(target: 'UserCredentials')]
    public UserCredentials $credentials;

    public function __construct()
    {
        $this->credentials = new UserCredentials();
    }
}
```

> **Note**Read more about [Embedded Entities](https://cycle-orm.dev/docs/relation-embedded).

#### BelongsToMorphed

[](#belongstomorphed)

```
use Cycle\Annotated\Annotation\Entity;
use Cycle\Annotated\Annotation\Relation\Morphed\BelongsToMorphed;

#[Entity]
class Image
{
    // ...

    #[BelongsToMorphed(taget: ImageHolderInterface::class)]
    public ImageHolderInterface $imageHolder;
}
```

> **Note**Read more about [BelongsToMorphed](https://cycle-orm.dev/docs/relation-morphed#belongstomorphed).

#### MorphedHasOne

[](#morphedhasone)

```
use Cycle\Annotated\Annotation\Entity;
use Cycle\Annotated\Annotation\Relation\Morphed\MorphedHasOne;

#[Entity]
class User
{
    // ...

    #[MorphedHasOne(target: Image::class)]
    public $image;
}
```

> **Note**Read more about [MorphedHasOne](https://cycle-orm.dev/docs/relation-morphed#morphedhasone).

#### MorphedHasMany

[](#morphedhasmany)

```
use Cycle\Annotated\Annotation\Entity;
use Cycle\Annotated\Annotation\Relation\Morphed\MorphedHasMany;

#[Entity]
class User
{
    // ...

    #[MorphedHasMany(target: Image::class)]
    public $images;
}
```

> **Note**Read more about [MorphedHasMany](https://cycle-orm.dev/docs/relation-morphed#morphedhasmany).

### Single Table Inheritance

[](#single-table-inheritance)

```
#[Entity]
#[DiscriminatorColumn(name: 'type')] // Discriminator column (required)
class Person
{
    #[Column(type: 'primary', primary: true)]
    protected int $id;

    #[Column(type: 'string')]
    protected string $name;
}

#[Entity]
#[InheritanceSingleTable]
class Employee extends Person
{
    #[Column(type: 'int')]
    protected int $salary;
}

#[Entity]
#[InheritanceSingleTable(value: 'foo_customer')]
class Customer extends Person
{
    #[Column(type: 'json')]
    protected array $preferences;
}
```

> **Note**Read more about [Single Table Inheritance](https://cycle-orm.dev/docs/advanced-single-table-inheritance).

### Joined Table Inheritance

[](#joined-table-inheritance)

```
#[Entity]
class Person
{
    #[Column(primary: true)]
    protected int $id;

    #[Column()]
    protected int $fooId;

    #[Column(type: 'string')]
    protected string $name;
}

#[Entity]
#[InheritanceJoinedTable(outerKey: 'fooId')]
class Employee extends Person
{
    #[Column(type: 'int')]
    protected int $salary;
}

#[Entity]
#[InheritanceJoinedTable(outerKey: 'id')]
class Customer extends Person
{
    #[Column(type: 'json')]
    protected array $preferences;
}
```

> **Note**Read more about [Joined Table Inheritance](https://cycle-orm.dev/docs/advanced-joined-table-inheritance).

License
-------

[](#license)

The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. Maintained by [Spiral Scout](https://spiralscout.com).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance67

Regular maintenance activity

Popularity8

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

193d ago

### Community

Maintainers

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

---

Top Contributors

[![roxblnfk](https://avatars.githubusercontent.com/u/4152481?v=4)](https://github.com/roxblnfk "roxblnfk (94 commits)")[![wolfy-j](https://avatars.githubusercontent.com/u/796136?v=4)](https://github.com/wolfy-j "wolfy-j (83 commits)")[![msmakouz](https://avatars.githubusercontent.com/u/67324318?v=4)](https://github.com/msmakouz "msmakouz (57 commits)")[![butschster](https://avatars.githubusercontent.com/u/773481?v=4)](https://github.com/butschster "butschster (16 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (7 commits)")[![rauanmayemir](https://avatars.githubusercontent.com/u/9691?v=4)](https://github.com/rauanmayemir "rauanmayemir (6 commits)")[![SerafimArts](https://avatars.githubusercontent.com/u/2461257?v=4)](https://github.com/SerafimArts "SerafimArts (4 commits)")[![puzzledpolymath](https://avatars.githubusercontent.com/u/162779269?v=4)](https://github.com/puzzledpolymath "puzzledpolymath (4 commits)")[![xepozz](https://avatars.githubusercontent.com/u/6815714?v=4)](https://github.com/xepozz "xepozz (2 commits)")[![gam6itko](https://avatars.githubusercontent.com/u/3841197?v=4)](https://github.com/gam6itko "gam6itko (2 commits)")[![KorDum](https://avatars.githubusercontent.com/u/1331559?v=4)](https://github.com/KorDum "KorDum (2 commits)")[![meekstellar](https://avatars.githubusercontent.com/u/44509066?v=4)](https://github.com/meekstellar "meekstellar (2 commits)")[![wpjscc](https://avatars.githubusercontent.com/u/76907477?v=4)](https://github.com/wpjscc "wpjscc (2 commits)")[![vjik](https://avatars.githubusercontent.com/u/525501?v=4)](https://github.com/vjik "vjik (1 commits)")[![makedo](https://avatars.githubusercontent.com/u/3338923?v=4)](https://github.com/makedo "makedo (1 commits)")[![alexndr-novikov](https://avatars.githubusercontent.com/u/7372962?v=4)](https://github.com/alexndr-novikov "alexndr-novikov (1 commits)")[![roquie](https://avatars.githubusercontent.com/u/3214290?v=4)](https://github.com/roquie "roquie (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/wpjscc-annotated/health.svg)

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[doctrine/doctrine-module

Laminas Module that provides Doctrine basic functionality required for ORM and ODM modules

3957.9M116](/packages/doctrine-doctrine-module)[api-platform/schema-generator

Various tools to generate a data model based on Schema.org vocables

4714.2M7](/packages/api-platform-schema-generator)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

134391.5k12](/packages/rector-rector-src)[mysql-workbench-schema-exporter/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

488188.5k10](/packages/mysql-workbench-schema-exporter-mysql-workbench-schema-exporter)[cycle/annotated

Cycle ORM Annotated Entities generator

28724.2k44](/packages/cycle-annotated)

PHPackages © 2026

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