Package

Spatie Laravel Data

Create unified resources and data transfer objects

Package

spatie/laravel-data

View on GitHub →

Overview

What Spatie Laravel Data does

Spatie's Laravel Data package allows developers to create unified resources and data transfer objects, simplifying data management across various parts of an application.

Laravel Data provides a way to streamline how data is handled throughout a Laravel application by using rich data objects. These objects replace the need for separate form requests, API transformers, and TypeScript definitions. Essentially, developers can describe their data once and use it consistently across different layers.

The package extends basic PHP objects by introducing a 'Data' class, which offers several key capabilities. These include transforming data objects into resources akin to Laravel's own API resources, and using lazy properties to only fetch what is necessary. Additionally, data objects can be created directly from request data with built-in validation.

A significant advantage is the automatic generation of TypeScript definitions from PHP data objects, facilitating seamless integration with frontend applications. This ensures that data remains typed as it moves between the backend and frontend, reducing potential errors and code duplication.

Developers benefit from writing less validation code, as the PHP type system helps infer validation rules. The ability to save data objects directly as properties of an Eloquent model further integrates them into the Laravel ecosystem, making the package appealing for applications that require consistent data handling practices.

This overview was generated by AI from the package README and may not reflect the latest release.

Read the full README →

Spatie Laravel Data Related Articles

Packistry is a Self-hosted Composer Repository Made with Laravel image

Packistry is a Self-hosted Composer Repository Made with Laravel

Read article
Laravel Personal Data Export image

Laravel Personal Data Export

Read article
Spatie  Multitenancy Package for Laravel image

Spatie Multitenancy Package for Laravel

Read article
Nimbus: An In-Browser API Testing Playground for Laravel image

Nimbus: An In-Browser API Testing Playground for Laravel

Read article
Building your own Laravel Packages image

Building your own Laravel Packages

Read article
Eloquent Attribute Casting image

Eloquent Attribute Casting

Read article
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Pushsilver logo

Pushsilver

Pushsilver is simple invoicing for freelancers and small studios — send polished invoices, automate reminders, and get paid on time without the bloat.

Pushsilver
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit