PHPackages                             andrepolo/lara-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. andrepolo/lara-dto

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

andrepolo/lara-dto
==================

Add data transfer objects to your Laravel app to transfer structured data

1.0.2(5y ago)1566MITPHPPHP ^7.2.5CI failing

Since Oct 24Pushed 3y ago2 watchersCompare

[ Source](https://github.com/andrepolo/lara-dto)[ Packagist](https://packagist.org/packages/andrepolo/lara-dto)[ RSS](/packages/andrepolo-lara-dto/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

lara-dto
========

[](#lara-dto)

Add data transfer objects to your Laravel app to transfer structured data

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

[](#installation)

To install the package to your laravel app, just require it using composer:

```
composer require andrepolo/lara-dto

```

To modify the config file, for example to change the default namespace of your data transfer item classes, you can eighter use the artisan command:

```
php artisan vendor:publish --tag=datatransfer-config

```

or use the command that comes with the package:

```
php artisan ap-dto:publish:config

```

After executing this you will find a new config file in your `app/config` directory: `datatransfer.php`

Creating Items and Collections
------------------------------

[](#creating-items-and-collections)

#### Creating a DataTransferItem class

[](#creating-a-datatransferitem-class)

The recommended way is to use the artisan command that ships with this package:

```
php artisan ap-dto:make:item

```

This command will create a new `DataTransferItem` with the given name and store it in the namespace which is defined in the config file `datatransfer.php` in the namespace section. If you pass a name like this `Subfolder\\NestedItem`, the class `NestedItem` will be stored in the folder `Subfolder` under the namespace. By default the namespace is `App\DataTransfer`. The command takes care if a class with the same name already exists in your directory. To force the command to overwrite this existing class (which is most unlikely in most cases) you can add the `-f` option in the make command. This is how this class would look like if you used the name `MyFirstDatatransferItem`:

```
