Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine Psql Enum Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

This package is a Doctrine DBAL custom type, not a Laravel/Eloquent package. It solves one narrow problem: mapping a PHP 8.1+ backed enum to a native PostgreSQL CREATE TYPE ... AS ENUM column, with conversion handled at the DBAL layer instead of in application code.

That means fit is conditional on a decision most Laravel shops have already made:

  • Eloquent-first stack (majority case): near-zero fit. Eloquent's enum handling is casts + string/integer columns. Laravel's $table->enum() on PostgreSQL emits a varchar plus a CHECK constraint, not a native enum type. Adopting this package to close that gap would mean introducing Doctrine DBAL purely as an enum shim — a large dependency for a small ergonomic win. Recommendation: do not adopt; use backed-enum casts plus a check constraint or a lookup table.
  • Doctrine ORM inside Laravel (via laravel-doctrine/orm): good fit. This is the intended audience, and the package removes hand-rolled Type subclasses that every Doctrine+Postgres team otherwise writes.
  • Doctrine DBAL standalone (migrations, reporting, legacy service): good fit if the team already owns DBAL type registration.

Integration feasibility

Mechanically simple: composer require, register the type in the DBAL type registry / config/doctrine.php custom types, annotate or attribute the entity column with the type name. No service provider, no config publishing, no runtime middleware, no Laravel container coupling — low blast radius.

The 3.4.2 release ("Pass registered types to underlying platform") touches exactly the seam that matters here. DBAL's platform object is what the schema comparator and migration diff consult when reasoning about column types; a custom type that is registered but invisible to the platform is the classic cause of phantom ALTER statements and failed introspection. This release is plausibly a targeted fix for that class of problem — which, if it holds, retires the single largest open integration risk in the previous assessment. It is stated in one line with no detail, so treat it as "likely improved, unverified."

The non-trivial work is still not the package. It is the surrounding Postgres DDL lifecycle:

  1. Schema tooling and CREATE TYPE. Even with platform awareness, DBAL's comparator does not author CREATE TYPE statements. The team must hand-author the CREATE TYPE in an initial migration and ensure ordering (type before table), plus idempotent guards for fresh environments. Verify the 3.4.2 behavior against doctrine:migrations:diff in a scratch database rather than assuming the release closes the gap.
  2. DBAL major-version API drift. DBAL 3 → 4 changed type registration and the Type contract materially, and "registered types to platform" is precisely a DBAL-4-era concern. Confirm the supported DBAL range against the project's lockfile before scoping, and confirm which line 3.4.2 was tested against.
  3. Existing column conversion. Moving a varchar column to a native enum requires ALTER TABLE ... ALTER COLUMN ... TYPE ... USING (...), which rewrites the table and takes an ACCESS EXCLUSIVE lock. On any non-trivial table this is a maintenance-window migration, not a deploy-time one.

Technical risk

  • Vendor concentration: still a single-maintainer project with negligible dependents. Zero downstream population means no one absorbs breakage before it reaches you. Treat as "code you are effectively adopting," with a fork-and-own contingency.
  • Thin test surface — now quantified. The 3.4.2 release reports 4 tests, 4 passed. That is the entire visible suite. Four tests cannot cover DBAL 3 and 4, comparator round-trips, nullability, default values, and invalid-label rejection simultaneously. Passing CI here is a smoke signal, not an assurance — in particular, do not read "4/4 green" as validation of the platform-registration change your integration depends on.
  • Bundled patch scope. The changelog compares 3.4.0 → 3.4.2, so the diff spans more than one patch version and may include changes not described in the headline. Review the commit range before pinning.
  • Metadata recency is still suspect. The prior release date (2026-08-07) is ahead of the current date. Re-verify actual release and commit history before citing recency as a health signal; the score inputs (overall 17.15, opportunity 27.16) remain consistent with a low-adoption niche utility, not a maturity endorsement.
  • Native Postgres enums are a schema-liability trade. The performance and integrity gains are real but modest. The costs are asymmetric: adding a value is an ALTER TYPE ... ADD VALUE (transaction-blocking caveats, and the new label is unusable in the same transaction that added it), while renaming or removing a value requires creating a replacement type, rewriting every dependent column, and dropping the old type. Under zero-downtime deploy constraints this is materially harder than a check constraint. The package makes the happy path pleasant and does nothing to soften the migration path.
  • Mature alternative exists. martin-georgiev/postgresql-for-doctrine covers Postgres enums plus ranges, IP types, and adjacent DBAL gaps with broader adoption and a larger test suite. Any build/buy decision should benchmark against it rather than against writing a type from scratch — and the 4-test disclosure strengthens that comparison.

Key questions for the team

  1. Is Doctrine ORM actually in the stack, or is this being evaluated for Eloquent? If Eloquent — stop here.
  2. Which DBAL major version is pinned, and does 3.4.2 declare and test support for it?
  3. Does the platform-registration change actually eliminate phantom ALTER statements in doctrine:migrations:diff on our schema? Prove it in a scratch database before relying on it.
  4. Who owns CREATE TYPE in the migration chain, and has a fresh-database bootstrap been proven end to end?
  5. Do we have any column that will change enum membership more than once a quarter? If yes, native enums may be the wrong primitive regardless of the package.
  6. Is fork-and-vendor acceptable if the maintainer goes dormant — and is a 4-test suite something we are willing to inherit?

Integration Approach

Stack fit

Requires PHP 8.1+ (native enums), PostgreSQL, Doctrine DBAL, and — for the intended use case — Doctrine ORM. In Laravel this implies laravel-doctrine/orm is already present and the team has accepted Doctrine's entity/metadata model alongside Eloquent. If the application is a hybrid (Eloquent for most models, Doctrine for a bounded context), scope this package strictly to the Doctrine-bounded entities; do not let it become the schema convention for the whole database.

Migration path

Three distinct paths, sequenced by risk:

  • Greenfield tables: lowest cost. Author the CREATE TYPE in the same migration file ahead of Schema::create, register the type, done.
  • Existing varchar/text columns: treat as a data migration. Add the new type, add a temporary enum column, backfill with a CASE mapping, swap, drop the old column — or accept a locked rewrite. Validate that every existing value maps to a case; unmapped values must fail the migration loudly, not silently null out.
  • Existing CHECK-constrained columns: simplest of the three — the value domain is already enforced, so the conversion is a type change plus dropping the constraint.

Compatibility

Pin the package exactly (not a caret range) — 3.4.2 specifically, given the changelog bundles 3.4.0 → 3.4.2 — and add a lockfile-diff review to the upgrade checklist for doctrine/dbal. Because 3.4.2 is a behavior change in how the platform sees registered types, re-run the comparator check after adopting it: confirm the type round-trips values and does not confuse doctrine:migrations:diff, which otherwise generates spurious ALTER statements on every diff — a slow-burn operational tax. Verify behavior under doctrine/dbal 3 and 4 if both appear across services; do not assume a single supported line, and do not assume 3.4.2 was exercised against both given the test count.

Sequencing

  1. Spike in a scratch database on 3.4.2: prove type registration, value round-trip, NULL handling, invalid-label rejection at the DB layer, fresh-schema bootstrap, and — new for this release — that migrations:diff produces an empty diff against a fully-migrated schema.
  2. Add a contract test that asserts the PHP enum case set equals the database's pg_enum label set — this is the highest-value artifact in the whole integration and survives any future package swap. It is also the only realistic compensation for a 4-test upstream suite.
  3. Convert one low-traffic table; measure lock duration.
  4. Roll the pattern out deliberately; document the enum-evolution runbook (add / rename / remove) before the second table, not after the first incident.
  5. Re-evaluate against the mature alternative at the six-month mark, or immediately if a DBAL major bump lands before the package declares support for it.

Operational Impact

Maintenance

The package is small and does one thing, so surface area for breakage is low — but the maintenance burden shifts to your migration code, which now carries hand-written Postgres DDL that DBAL cannot diff or reverse. Budget ongoing owner time for the enum-evolution runbook, not for the dependency. Pin the version, mirror the repository internally, and pre-agree a fork trigger (maintainer unresponsive >90 days with an open breaking issue). The 3.4.2 change increases the value of mirroring: a platform-registration fix is the kind of thing that can regress silently on a DBAL upgrade, and you want the ability to patch it yourself.

Support

No commercial support, no SLA, single maintainer, and a four-test suite. Escalation is a GitHub issue against a low-star project. Internal capability — someone who can read DBAL's Type contract, read a platform implementation, and write a Postgres DDL migration — is the real support plan. Confirm that person exists before adoption; if not, the cheap dependency is actually an expensive one.

Scaling

Read paths are unaffected. Write and DDL paths are where scale bites: enum changes take ACCESS EXCLUSIVE locks and, for renames/removals, rewrite dependent tables. At small table sizes this is invisible; at tens of millions of rows it becomes a scheduled maintenance event. Also confirm the connection pooler in use (PgBouncer, RDS Proxy) handles the prepared-statement patterns DBAL emits — a generic DBAL concern, not package-specific, but it surfaces at the same moment.

Failure modes

  • Fresh environment bootstrap fails because CREATE TYPE was added to an incremental migration but not to the base schema path.
  • doctrine:migrations:diff still emits phantom ALTER statements. 3.4.2 plausibly reduces this, but with four tests and no described verification of the comparator path, treat it as open until proven on our schema.
  • Platform-registration behavior regresses on a DBAL minor/major bump, re-introducing introspection noise with no upstream test to catch it.
  • Insert fails on a label present in PHP but absent from the database after a deploy that shipped code before migration (ordering hazard — always migrate before deploying enum-case additions, and never remove a label in the same release that stops writing it).
  • ALTER TYPE ... ADD VALUE inside a transactional migration fails or leaves the new label unusable in that transaction, breaking seeders that rely on the new case.
  • DBAL bump silently unregisters the type, producing "unknown column type" errors at boot rather than at query time.
  • Nullability and default-value handling diverge between the DB column and the PHP enum, surfacing as type errors on hydration — untested territory in a 4-test suite.

Ramp-up

Low for a developer fluent in Doctrine metadata and Postgres DDL — roughly a day to a working spike. High for an Eloquent-only team, because the real learning curve is Doctrine's type system and Postgres enum DDL semantics, not this package. Estimate accordingly, and treat the contract test plus runbook as the deliverable, with the dependency as an implementation detail.

Recommendation: unchanged in direction, slightly improved in confidence. Adopt only inside an existing Doctrine ORM context, pinned to 3.4.2, with a fresh-schema test, an empty-diff test, and an enum-evolution runbook as gating prerequisites. The 3.4.2 platform change is directionally the right fix for the package's most painful integration risk, but a four-test suite means our own verification carries the weight — do not adopt on the strength of the release note. Otherwise, decline and use backed-enum casts with a check constraint.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console