ascetic-soft/rowcast
Lightweight PDO DataMapper for PHP 8.4+ that maps DB rows to DTOs and back via reflection. Supports auto or explicit mappings, type conversion, and a fluent query builder with dialect-aware UPSERT.
| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Performance Overhead | Medium | Benchmark with production-like query volumes. Use select() to limit columns cast. |
| Type Safety | High | Validate casted types in application logic. Avoid runtime errors via @phpstan-ignore. |
| Query Complexity | Medium | Document casted fields in API schemas (OpenAPI/Swagger). |
| Dependency Bloat | Low | Package is lightweight (~500 LOC). No external deps. |
| Future Laravel Breaks | Medium | Monitor Laravel’s Illuminate\Database changes. Fork if needed. |
User::query()->cast(['profile' => JsonCast::class])->get().protected $casts = ['profile' => 'array']; (native) vs. row-level casting.composer require ascetic-soft/rowcast.use AsceticSoft\RowCast\Casts\JsonCast;
$users = User::query()->cast(['metadata' => JsonCast::class])->limit(10)->get();
jsonb_build_object).JSON_EXTRACT workarounds for nested casts.json() casts.JsonCast, DateCast).CASTING_RULES.md.10k+ rows; optimize queries.report().DB::enableQueryLog().^1.0 in composer.json until stability is proven.CastException: Invalid data format (e.g., non-JSON string).QueryException: Unsupported DB functions (e.g., SQLite JSON casts).dd($query->toSql(), $query->getBindings()) to inspect raw queries.debugbar for query profiling.UrlCast, CollectionCast).$cached = Cache::remember("user_{$user->id}_cast", now()->addHours(1), fn() =>
User::find($user->id)->cast(['profile' => JsonCast::class])
);
ab or k6.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Malformed Data | CastException crashes request. | Use try-catch or optional()->cast(). |
| DB Function Unavailable | Query fails (e.g., SQLite). | Fallback to PHP-side casting. |
| Package Abandoned | No updates/security fixes. | Fork or replace with custom logic. |
| Performance Regression | Slow queries under load. | Rate-limit or disable casts. |
EnumCast, SerializedCast).metadata is always an array").How can I help you explore Laravel packages today?