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
Laravel Casts

Laravel Casts Laravel Package

genealabs/laravel-casts

GeneaLabs Laravel Casts adds flexible custom attribute casting to Eloquent models, making it easy to map database columns to value objects, DTOs, and other PHP classes. Keeps model code clean and cast logic reusable, testable, and simple to configure.

View on GitHub
Deep Wiki
Context7

GeneaLabs Laravel Casts lets Eloquent models cast attributes to custom PHP classes—value objects, DTOs, money, addresses—instead of being limited to primitives. Register a cast class on your model and the package handles converting values between the database representation and your object on every read and write.

  • Cast attributes to any class, not just scalars
  • Automatic serialization and deserialization in both directions
  • Flexible storage formats, including JSON and arrays
  • Handles nullable columns safely
  • Drop-in support for existing Eloquent models
Frequently asked questions about Laravel Casts
What is genealabs/laravel-casts actually for?
The package documentation describes an Eloquent custom-cast layer for value objects, but the repository listing and changelog indicate it is actually a set of Blade form macros. A technical review found the casting story is a documentation error, since native CastsAttributes has covered custom Eloquent casts since Laravel 7. Treat this package as legacy form markup tooling, not as a casting solution.
Does genealabs/laravel-casts support custom Eloquent casts for value objects or DTOs?
No. The credible reading of this package is a Blade form-macro layer, and the value-object casting description is a documentation error. Laravel's native CastsAttributes, available since Laravel 7, already handles casting attributes to custom classes. For money, addresses, or DTOs, use native casts plus purpose-built libraries such as moneyphp/money or propaganistas/laravel-phone.
Is genealabs/laravel-casts still maintained?
It has been archived since February 2024, has around 109 stars, and has no upstream maintainer to file issues against. There is no patch path, so compatibility and security fixes become internal work items indefinitely. If you are forced to adopt it for legacy continuity, pin the exact version 0.13.3 rather than using a caret or tilde.
Which Laravel and PHP versions does genealabs/laravel-casts support?
Compatibility claims should be treated as stale and unverified. The package has zero dependents, so there is no field evidence that it works on your Laravel or PHP version. Before any commitment, inspect the real composer.json requirements and the macros actually defined in src rather than relying on the listing or README.
How do I install genealabs/laravel-casts?
It is installable via Composer with auto-discovered providers, but you should verify the real composer.json requirements first. Pin the exact version 0.13.3, because the Tel label fix landed there and earlier versions render telephone fields incorrectly with no future fix. The underlying form-macro reading also depends on laravelcollective/html, which is itself archived.
Does genealabs/laravel-casts depend on laravelcollective/html?
Under the form-macro reading, yes, and laravelcollective/html is archived as well. Adopting this package can therefore mean adopting one unmaintained package to get another, and you inherit Form::open's CSRF and method-spoofing behaviour along the way. Check whether laravelcollective/html is already pinned in your dependency graph for other reasons before adding anything.
Is genealabs/laravel-casts safe to use in production, and does it escape output?
Escaping has not been verified, and labels, placeholders, and attribute arrays funnel into string concatenation. An unmaintained macro that skips e() is an XSS vector with no security release coming. Audit the actual source before use, and immediately verify CSRF token handling, method spoofing, old() repopulation, and that $errors renders beside the field.
What are alternatives to genealabs/laravel-casts for form markup?
On Laravel 7 and later, native Blade components with @props are first-party, dependency-free, and have no laravelcollective/html tail. If you genuinely want PHP-built markup, spatie/laravel-html is maintained and covers that style. For value objects, use native CastsAttributes plus purpose-built libraries; neither need points at this package on a modern stack.
What risks come with genealabs/laravel-casts macro registration?
The macros register onto the Form facade's Macroable surface, which is global mutable state shared with every other provider in the application. Last registration quietly wins across packages and teammates' service providers, so namespace collisions are possible. Breakage is also silent: rendered HTML can diverge after a framework bump and surface at form submission rather than in a stack trace.
How do I migrate away from genealabs/laravel-casts and make it removable?
Inventory actual macro usage with a grep such as Form::(tel|email|date|...) across resources/views, because anything you do not call is pure liability. Wrap every macro call in a project-owned Blade partial or component so swapping it later touches one file instead of every call site. Then replace those wrappers with native x-input components or another maintained alternative and remove the dependency.
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