spatie/laravel-morph-map-generator
Automatically generates and keeps Laravel Eloquent morph maps up to date. Models register themselves by implementing getMorphClass(), so you don’t forget to add entries. Optional auto-generation on app boot, configurable for custom model locations.
Image, Video, Document models for polymorphic mediaable() relationships.Post, Comment, UserProfile without manual map updates.tenantable()) without syncing maps across environments.Adopt if:
morphTo, morphWith) with >10 models.php artisan morph:map or forget to update maps after adding models.Look Elsewhere if:
For Executives:
"This package eliminates a tedious, error-prone task—maintaining morph maps—by auto-registering models when they implement getMorphClass(). For apps with polymorphic features (e.g., media libraries, audit logs), it reduces dev time by ~10% and cuts deployment risks from forgotten map updates. MIT-licensed, zero dependents, and backed by Spatie’s track record—low risk, high ROI."
For Engineering:
"Replace manual php artisan morph:map with zero-effort registration. Just add getMorphClass() to your models, and the package handles the rest. Works seamlessly with Laravel’s polymorphic system, supports all recent versions, and includes tests/PSR-12 compliance. Tradeoff: loses explicit map visibility, but gains reliability and speed."
How can I help you explore Laravel packages today?