PHP code example of andrepolo / lara-dto

1. Go to this page and download the library: Download andrepolo/lara-dto library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

andrepolo / lara-dto example snippets




namespace App\DataTransfer;

use AndrePolo\LaraDto\DataTransferItem;

class MyFirstDatatransferItem extends DataTransferItem
{
    // add your properties here
}

// simly with new up a class
$item = new ExampleItem();

// using laravels service container
$item = app()->make(ExampleItem::class);

// or if you registered your class with an alias
$item = app()->make('class_alias');



namespace App\DataTransfer;

use AndrePolo\LaraDto\DataTransferCollection;

class MyFirstDatatransferCollection extends DataTransferCollection
{
    protected $itemClass = MyFirstDatatransferItem::class;
}

$item = new ExampleItem($data);

$item = new ExampleItem();
$item->fromArray($data);

protected function useSetter()
{
    return false;
}

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

php artisan ap-dto:publish:config

php artisan ap-dto:make:item

php artisan ap-dto:make:collection