PHPackages                             oilytortoise/laravel-simple-dto - 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. oilytortoise/laravel-simple-dto

ActiveLibrary

oilytortoise/laravel-simple-dto
===============================

A simple DTO package for Laravel

v1.0.3(6mo ago)1337MITPHPPHP ^8.0

Since Sep 7Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/oilytortoise/laravel-simple-dto)[ Packagist](https://packagist.org/packages/oilytortoise/laravel-simple-dto)[ RSS](/packages/oilytortoise-laravel-simple-dto/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

laravel-simple-dto
==================

[](#laravel-simple-dto)

Composer Package for creating simple DTOs (Data Transfer Objects) in the Laravel framework

Github: \[\]
Packagist: \[\]

Changes
-------

[](#changes)

### v1.0.2

[](#v102)

- Removed `implements Wireable` from `AbstractDto` to allow usage in back-end services without installing Livewire.
    - Simply add `implements Wireable` to your DTOs in order to use them in Livewire components.

Installation
------------

[](#installation)

`composer require oilytortoise/laravel-simple-dto`

Assets
------

[](#assets)

The package consists of two key classes:

- `AbstractDto`
- `AbstractDtoCollection`

Usage
-----

[](#usage)

DTOs are a handy data structure to help send data around your application, generate API payloads/responses, hydrate incoming request data etc.

While all of this can be done with simple arrays, DTOs have the added benefit of being able to easily typecast values being stored, customize hydration logic, and add any functions for getting and setting values where necessary (however it is generally not advised to include business logic within a DTO).

### Creating a DTO

[](#creating-a-dto)

A DTO class is very simple to create. Here is an example:

```
