heymoon/doctrine-psql-enum
A Doctrine DBAL type for PostgreSQL enums, making it easy to define and use native enum columns in Laravel/PHP applications. Provides seamless mapping and schema integration for cleaner, type-safe database models.
$table->string('status') + validation, or do we enforce the value set in the database?" becomes a real architectural choice rather than a default. Directly relevant to status/state columns: order lifecycle, payment state, subscription tier, fulfillment stage, KYC/onboarding steps.Doctrine\DBAL\Types\Type subclass plus conversion/SQL-declaration logic. This package collapses that to a config line — a low-cost procurement decision, not a platform bet.ALTER TYPE ... ADD VALUE has transactional and ordering constraints, and value removal requires a type rewrite. Adopting this forces us to decide how enum evolution is governed — a process question the PM owns as much as engineering.pending_review") because invalid states cannot exist in the table.doctrine/dbal.Adopt when:
Look elsewhere when:
enum cast — that already covers most CRUD needs with zero new dependencies.For executives (one paragraph): This is a small, MIT-licensed integration library that lets our PHP code and our PostgreSQL database share one authoritative definition of closed value sets like order status or payment state. The business value is data integrity: invalid states become impossible to write rather than merely rejected by application code, which reduces a recurring class of bugs and clean-up work in reporting and audits. Cost is low — a thin adapter, roughly a day or two of engineering — and the license carries no commercial obligation. The main risk is not technical but organizational: the project is early-stage with a single maintainer and almost no downstream adoption, so we should pilot it in one bounded domain, pin the version, and keep a trivial fallback to a constrained string column. Recommendation: approve a scoped spike, not a platform-wide standard.
For engineering (the practical case): It provides a Doctrine DBAL custom type mapping PHP 8.1 backed enums to PostgreSQL CREATE TYPE ... AS ENUM, so enum values live in one place and schema comparisons work. Integration is configuration, not code. The tradeoffs to accept up front: ALTER TYPE ... ADD VALUE cannot be rolled back inside a transaction and older PG versions restrict its use in some migration contexts, so enum evolution needs its own migration playbook; the type is not removable without a full rewrite; and Doctrine DBAL must be a first-class dependency rather than an incidental one. Before adoption we want a code review of the type implementation, a pinned version, and a documented exit path (revert to varchar + CHECK constraint) so the pilot cannot become a lock-in.
How can I help you explore Laravel packages today?