pugx/shortid-doctrine-bundle
Symfony bundle that integrates PugX ShortId with Doctrine ORM, giving entities short, unique, human-friendly identifiers generated automatically on persist. Ideal for clean URLs and readable public IDs.
pugx/shortid-doctrine-bundle is a Symfony bundle. It wires up the shortid Doctrine DBAL type from pugx/shortid-doctrine (a Hashids-backed encoder) via Symfony's DI container. There is no Laravel service provider, no facade, no publishable config — composer require on a stock Laravel app gets you a package that does nothing.hashids/hashids (or sqids/sqids) directly and do the encode/decode in an accessor or a cast. That covers the entire feature set of this package in ~15 lines with no Doctrine dependency.laravel-doctrine/orm, or a hybrid app), install only pugx/shortid-doctrine — not the bundle — and register the type yourself in a service provider's boot():
Type::addType('shortid', \PUGX\Shortid\Doctrine\ShortIdType::class);
type: 'shortid', generated on insert, so URLs and API payloads carry aB3xK9 instead of 1042.ShortIdType::convertToPHPValue() to understand that hydration hands you a value object, not a string. That single detail drives most of the friction below.type="shortid" and pair it with a custom id generator (#[ORM\GeneratedValue(strategy: 'CUSTOM')] + #[ORM\CustomIdGenerator(...)]), or assign in the constructor/prePersist. The custom-generator route is cleaner because it guarantees the id exists before any flush-time listener runs.ShortId, so (string) $entity->getId() at the serialization boundary, and implement JsonSerializable on the entity (or use a normalizer) so toArray() doesn't emit an object graph.find($shortString) and ->where('id', $shortString) bind as a plain string; comparisons work because the column is physically a varchar, but you bypass the type's validation and can silently match garbage. Wrap explicitly with ->setParameter('id', $short, 'shortid') when correctness matters.shortid for free; on Laravel you write a Route::bind('user', fn ($v) => User::find($v) ?? abort(404)) or resolveRouteBinding() in the model. One place, do it once.config/ sourced from .env, never committed.Type::addType() must run before Doctrine builds metadata. Registering in a queued job, an artisan command, or a package provider that loads late will produce "Unknown column type shortid" only in those contexts — a classic intermittent bug. Put it in a provider that's always booted.v1.3.0 against Symfony 8 you were only seeing deprecation notices; the underlying pugx/shortid-doctrine type is unchanged.tinker, Doctrine\DBAL\Types\Type::hasType('shortid') tells you instantly whether the provider ran. If that's false, no amount of entity annotation debugging will help.How can I help you explore Laravel packages today?