Skip to content

Entity Definition

lpachecob edited this page Mar 22, 2026 · 4 revisions

🧬 Entity Definition: Attribute Reference

In BOUNDLY, your domain entities are your database schema. No migrate files needed. Just attributes.


🔝 #[Entity]

Required for every persistent class.

Property Default Description
table NULL The DB table name.
resource NULL The API resource name (plural).
primaryKey 'id' The PK column name.
connection 'mysql' DB connection to use.
#[Entity(table: 'users', resource: 'users')]
class User extends AggregateRoot { ... }

💠 #[Column]

Defines the DB column properties.

Property Default Description
type 'string' The type (string, integer, boolean, decimal, etc.).
length 255 Max length for strings.
nullable false If TRUE, the DB column will allow NULLs.
default NULL The default value for the column.
unique false If TRUE, adds a unique index in the DB.
#[Column(type: 'string', length: 150, unique: true)]
private string $email;

🆔 #[Id]

Marks the primary key of the entity. Generally used with private int $id.


🏗️ Supported Column Types

  • string (VARCHAR)
  • text (TEXT)
  • integer (INT)
  • boolean (TINYINT)
  • decimal (DECIMAL)
  • date / datetime / timestamp
  • json (JSON)

🧪 Example

#[Entity(table: 'posts', resource: 'posts')]
class Post extends AggregateRoot
{
    #[Id]
    private int $id;

    #[Column(type: 'string', length: 100)]
    private string $title;

    #[Column(type: 'text')]
    private string $content;

    #[Column(type: 'boolean', default: false)]
    private bool $is_published;
}

Next Step: Action-Definition 🚀

Clone this wiki locally