All Projects → cycle → annotated

cycle / annotated

Licence: MIT license
Schema generation using annotated entities and mappers

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to annotated

Easy-Fragment-Argument
This library will help you to pass and receive fragment arguments in easier way
Stars: ✭ 17 (-10.53%)
Mutual labels:  annotations
django-sqlalchemy
Django ORM built on top of SQLalchemy core 2.0 for seamless integration of SQLAlchemy with Django 4.1+ PostgreSQL 14+ only for now. [pre POC now]
Stars: ✭ 101 (+431.58%)
Mutual labels:  datamapper
kibana-comments-app-plugin
An application plugin to add and visualize comments to your Kibana dashboards
Stars: ✭ 36 (+89.47%)
Mutual labels:  annotations
twc
TypeScript based, boilerplate-less, Polymer toolbox friendly Polymer Modules
Stars: ✭ 33 (+73.68%)
Mutual labels:  annotations
pyheartex
Heartex Python SDK - Connect your own models to Heartex Data Labeling
Stars: ✭ 27 (+42.11%)
Mutual labels:  annotations
accelerator-core-js
Accelerator Core provides a simple way to integrate real-time audio/video into your web application using the OpenTok Platform
Stars: ✭ 24 (+26.32%)
Mutual labels:  annotations
hyperion
Experimental framework for working with IIIF in JavaScript and Typescript.
Stars: ✭ 17 (-10.53%)
Mutual labels:  annotations
zf-dependency-injection
Advanced dependency injection for laminas framework
Stars: ✭ 17 (-10.53%)
Mutual labels:  annotations
PersianNER
Named-Entity Recognition in Persian Language
Stars: ✭ 48 (+152.63%)
Mutual labels:  annotations
AnnotationInject
Compile-time Swift dependency injection annotations
Stars: ✭ 40 (+110.53%)
Mutual labels:  annotations
task-bundle
Scheduling of tasks for symfony made simple
Stars: ✭ 33 (+73.68%)
Mutual labels:  annotations
PrimeAdapter
PrimeAdapter makes working with RecyclerView easier.
Stars: ✭ 54 (+184.21%)
Mutual labels:  annotations
aptk
A toolkit project to enable you to build annotation processors more easily
Stars: ✭ 28 (+47.37%)
Mutual labels:  annotations
aioapi
Yet another way to build APIs using AIOHTTP framework
Stars: ✭ 14 (-26.32%)
Mutual labels:  annotations
graphql-metadata
Annotate your graphql schema with lightweight directives
Stars: ✭ 28 (+47.37%)
Mutual labels:  annotations
amigo
AmiGO is the public interface for the Gene Ontology.
Stars: ✭ 26 (+36.84%)
Mutual labels:  annotations
dart sealed
Dart and Flutter sealed class generator and annotations, with match methods and other utilities. There is also super_enum compatible API.
Stars: ✭ 16 (-15.79%)
Mutual labels:  annotations
aspecio
Aspecio, AOP Proxies for OSGi services
Stars: ✭ 14 (-26.32%)
Mutual labels:  annotations
gum
Repository for the Georgetown University Multilayer Corpus (GUM)
Stars: ✭ 71 (+273.68%)
Mutual labels:  annotations
phpunit-injector
Injects services from a PSR-11 dependency injection container to PHPUnit test cases
Stars: ✭ 62 (+226.32%)
Mutual labels:  annotations

Cycle ORM - Annotated Entities

Latest Stable Version Build Status Scrutinizer Code Quality Codecov

Simple example:

Annotation definition

/**
 * @Entity(
 *     role="user",
 *     repository="Repository/UserRepository",
 *     typecast="Typecast\AutoTypecaster"
 * )
 */
class User
{
    /** @Column(type="primary") */
    protected $id;
    
    /** @HasOne(target=Profile::class, load="eager") */
    protected $profile;
    
    /** @HasMany(target=Post::class, load="lazy") */
    protected $posts;
   
    /** 
     * @ManyToMany(
     *     target=Tag::class, 
     *     through=TagMap::class, 
     *     load="lazy", 
     *     collection="Collection\BaseCollection"
     * )
     */
    protected $tags;
    
    ...
}

Attribute definition

#[Entity(
    role: "user", 
    repository: Repository/UserRepository::class, 
    typecast: Typecast\Typecaster::class
)]
class User
{
    #[Column(type: 'primary')]
    protected $id;
    
    #[HasOne(target: Profile::class, load: "eager")]
    protected $profile;
    
    #[HasMany(target: Post::class, load: "lazy")]
    protected $posts;
   
    #[ManyToMany(
        target: Tag::class, 
        through: TagMap::class, 
        load: "lazy", 
        collection: Collection\BaseCollection::class
    )]
    protected $tags;
    
    ...
}

STI/JTI:

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;
}

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;
}

Combined example

#[Entity]
#[DiscriminatorColumn(name: 'type')]
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;
}

#[Entity]
#[InheritanceJoinedTable(outerKey: 'foo_id')]
class Executive extends Employee
{
    #[Column(type: 'int')]
    protected int $bonus;
}

Schema modifiers:

Schema modifier example

namespace App\SchemaModifiers;

use Cycle\ORM\SchemaInterface;
use Cycle\Schema\Registry;
use Cycle\Schema\SchemaModifierInterface;

#[\Attribute(\Attribute::TARGET_CLASS)]
class MapperSegmentSchemaModifier implements SchemaModifierInterface
{
    private string $role;
        
    public function __construct(
        private string $class
    ) {
    }

    public function withRole(string $role): static
    {
        $this->role = $role;
        return $this;
    }

    public function compute(Registry $registry): void 
    {
        // ...
    }

    public function render(Registry $registry): void 
    {
        // ...
    }

    public function modifySchema(array &$schema): void
    {
        $schema[SchemaInterface::MAPPER] = $this->class;
    }
}

Usage

namespace App\Entities;

use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use App\SchemaModifiers\MapperSegmentSchemaModifier;

#[Entity]
#[MapperSegmentSchemaModifier(class: SuperMapper::class)]
class Post
{
    #[Column(type: 'integer', primary: true)]
    protected int $id;

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

License:

The MIT License (MIT). Please see LICENSE for more information. Maintained by Spiral Scout.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].