PHPackages                             davidkvasnovsky/laravel-data - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. davidkvasnovsky/laravel-data

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

davidkvasnovsky/laravel-data
============================

Create unified resources and data transfer objects

1.4.5(4y ago)07MITPHPPHP ^8.0

Since Jun 30Pushed 4y agoCompare

[ Source](https://github.com/davidkvasnovsky/laravel-data)[ Packagist](https://packagist.org/packages/davidkvasnovsky/laravel-data)[ Docs](https://github.com/spatie/laravel-data)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/davidkvasnovsky-laravel-data/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (14)Versions (36)Used By (0)

[![](https://camo.githubusercontent.com/2bedf63f24cda7efab02da955dc11fb7ef8a060e2f26b73c33a7aac84529b8a3/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f737570706f72742d756b7261696e652e7376673f743d31)](https://supportukrainenow.org)

Powerful data objects for Laravel
=================================

[](#powerful-data-objects-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/04708cf608a34e47ac9147191b5abdf2d7ca652b0f5005a7455e99755b7d89a4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d646174612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-data)[![GitHub Tests Action Status](https://camo.githubusercontent.com/28a4be46c2c00f5a398a528f1b9cdb7cc561d1bf44dd48c1170890ee4b36f642/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d646174612f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/spatie/laravel-data/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/709a6c993f5ff12006fb79f7b27a4aa4009e92d536c48f2404f10cb39f4970b6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d646174612f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/spatie/laravel-data/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/3cbd97b845d0cd41ecaf5a0cf1f1756c11f0e16288aa03e6f7c2b500c780b8bd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d646174612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-data)

This package enables the creation of rich data objects which can be used in various ways. Using this package you only need to describe your data once:

- instead of a form request, you can use a data object
- instead of an API transformer, you can use a data object
- instead of manually writing a typescript definition, you can use... 🥁 a data object

A `laravel-data` specific object is just a regular PHP object that extends from `Data`:

```
use Spatie\LaravelData\Data;

class SongData extends Data
{
    public function __construct(
        public string $title,
        public string $artist,
    ) {
    }
}
```

By extending from `Data` you enable a lot of new functionality like:

- Automatically transforming data objects into resources (like the Laravel API resources)
- Transform only the requested parts of data objects with lazy properties
- Automatically creating data objects from request data and validating them
- Automatically resolve validation rules for properties within a data object
- Make it possible to construct a data object from any type you want
- Add support for automatically validating data objects when creating them
- Generate TypeScript definitions from your data objects you can use on the frontend
- Save data objects as properties of an Eloquent model
- And a lot more ...

Why would you be using this package?

- You can be sure that data is typed when it leaves your app and comes back again from the frontend which makes a lot less errors
- You don't have to write the same properties three times (in a resource, in a data transfer object and in request validation)
- You need to write a lot less of validation rules because they are obvious through PHP's type system
- You get TypeScript versions of the data objects for free

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/db4182c9f754c4512017c316b58e9d5f00206e00eab9324e793913f3f63bb50d/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d646174612e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-data)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Documentation
-------------

[](#documentation)

You will find full documentation on the dedicated [documentation](https://spatie.be/docs/laravel-data/v1/introduction) site.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Ruben Van Assche](https://github.com/rubenvanassche)
- [Aidan Casey](https://github.com/aidan-casey) (Validation Attributes)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 73% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

32

Last Release

1510d ago

Major Versions

0.0.9 → 1.0.02021-10-27

1.4.5 → v2.x-dev2022-03-21

PHP version history (2 changes)0.0.1PHP ^8.0

v2.x-devPHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/fa6b1d065264c3119cb000ec39b917e194849a98266bc1270b06e9caa9d82d6e?d=identicon)[davidkvasnovsky](/maintainers/davidkvasnovsky)

---

Top Contributors

[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (241 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (51 commits)")[![abenerd](https://avatars.githubusercontent.com/u/7523903?v=4)](https://github.com/abenerd "abenerd (5 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (5 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (4 commits)")[![aidan-casey](https://avatars.githubusercontent.com/u/6686277?v=4)](https://github.com/aidan-casey "aidan-casey (4 commits)")[![davidkvasnovsky](https://avatars.githubusercontent.com/u/12381721?v=4)](https://github.com/davidkvasnovsky "davidkvasnovsky (3 commits)")[![alexrififi](https://avatars.githubusercontent.com/u/21067613?v=4)](https://github.com/alexrififi "alexrififi (3 commits)")[![juliomotol](https://avatars.githubusercontent.com/u/21353103?v=4)](https://github.com/juliomotol "juliomotol (3 commits)")[![ace18](https://avatars.githubusercontent.com/u/47694935?v=4)](https://github.com/ace18 "ace18 (2 commits)")[![LaravelFreelancerNL](https://avatars.githubusercontent.com/u/36150929?v=4)](https://github.com/LaravelFreelancerNL "LaravelFreelancerNL (1 commits)")[![morrislaptop](https://avatars.githubusercontent.com/u/67807?v=4)](https://github.com/morrislaptop "morrislaptop (1 commits)")[![ReDev1L](https://avatars.githubusercontent.com/u/2886885?v=4)](https://github.com/ReDev1L "ReDev1L (1 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (1 commits)")[![cristiancalara](https://avatars.githubusercontent.com/u/6623183?v=4)](https://github.com/cristiancalara "cristiancalara (1 commits)")[![danyellnoe](https://avatars.githubusercontent.com/u/12405298?v=4)](https://github.com/danyellnoe "danyellnoe (1 commits)")[![ahoiroman](https://avatars.githubusercontent.com/u/23051150?v=4)](https://github.com/ahoiroman "ahoiroman (1 commits)")[![gauravmak](https://avatars.githubusercontent.com/u/11887260?v=4)](https://github.com/gauravmak "gauravmak (1 commits)")[![hxnk](https://avatars.githubusercontent.com/u/1008127?v=4)](https://github.com/hxnk "hxnk (1 commits)")

---

Tags

spatielaravellaravel-data

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/davidkvasnovsky-laravel-data/health.svg)

```
[![Health](https://phpackages.com/badges/davidkvasnovsky-laravel-data/health.svg)](https://phpackages.com/packages/davidkvasnovsky-laravel-data)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M626](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[spatie/laravel-rdap

Perform RDAP queries in a Laravel app

72108.3k2](/packages/spatie-laravel-rdap)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[spatie/laravel-screenshot

Take screenshots of web pages in Laravel apps

7615.9k2](/packages/spatie-laravel-screenshot)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
