Skip to content

Dynamic Model

The Dynamic Model engine is the core of Doggy's low-code platform. It uses @Ef annotations combined with PHP 8 Attributes to mark business fields, auto-generating database migrations, APIs, and admin interfaces.

Overview

The dynamic model system is built on two core annotations defined in src/Annotation/:

  • Ef: Marks business field groups and metadata properties
  • EfGroup: Defines field groups
php
// src/Annotation/Ef.php
class Ef
{
    public $value = [];

    public function __construct(array $data)
    {
        $this->value['group'] = $data['group'] ?? null;
        $this->value['bf'] = $data['isBF'] ?? false;
    }
}

Defining a Model

php
namespace App\Entity\Organization;

use App\Annotation\Ef;
use App\Entity\Traits\CommonTrait;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'org_department')]
class Department
{
    use CommonTrait;

    #[ORM\Id]
    #[ORM\Column(type: 'uuid', unique: true)]
    #[ORM\GeneratedValue(strategy: 'CUSTOM')]
    #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
    private $id;

    #[Ef(displayName: 'Department Name', required: true)]
    #[ORM\Column(length: 100)]
    private string $name;

    #[Ef(displayName: 'Department Code', searchable: true)]
    #[ORM\Column(length: 50, nullable: true)]
    private ?string $code = null;
}

Entity Management

Manage entities at Low-Code Platform → Entity Management (App\Controller\Admin\Platform\EntityController).

Core Entity Directories

DirectoryEntitiesDescription
Entity/Organization/Department, Company, Corporation, Employee, Position, PositionLevelOrganization & employees
Entity/Platform/Entity, EntityProperty, View, ViewField, DataGrid, Menu, DataSourceLow-code engine
Entity/Security/PasswordPolicy, PasswordStrengthRule, PasswordResetMethod, WebauthnCredentialSecurity
Entity/Storage/File, StorageConfig, UploadSessionFile storage
Entity/System/AuditLog, Task, TaskLog, EmailConfig, EmailTemplate, EmailLog, SystemCalendarEventInfrastructure

CommonTrait

All entities combine capabilities via CommonTrait (src/Entity/CommonTrait.php):

php
trait CommonTrait
{
    use SoftDeleteableEntity;    // deletedAt field
    use TimestampableEntity;     // createdAt, updatedAt
    use BlameableEntity;        // createdBy, updatedBy

    #[ORM\ManyToOne(targetEntity: Corporation::class)]
    private $corporation;

    #[ORM\ManyToOne(targetEntity: Company::class)]
    private $company;
}

Auto-Generation

Commands like EfInitEntityCommand automatically handle:

  • Database migration generation
  • CRUD interface rendering
  • Validation rules
  • Permission checks

Admin Interface

Navigate to Low-Code Platform → Entity Management (/admin/platform/entity) for visual operations:

  • Entity property editing (EntityProperty)
  • Property group management (EntityPropertyGroup)
  • One-click migration generation
  • Relationship configuration

Open Source under MIT | Copyright © 2026 Doggy