1. Go to this page and download the library: Download valeryq/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/ */
valeryq / dto example snippets
"valeryq/dto": "1.0.0"
'Valeryq\DTO\DTOServiceProvider',
'DTO' => 'Valeryq\DTO\DTOFacade',
class UserController extends \BaseController
{
public function getUser()
{
$user = UserModel::find(1);
return DTO::make($user)->only(['id', 'firstname']);
or
return DTO::make($user)->except(['lastname']);
}
}
class UserController extends \BaseController
{
public function getUser()
{
$user = UserModel::where('firstname', 'Test')->get();
return DTO::make($user)->only(['id', 'firstname']);
or
return DTO::make($user)->except(['lastname']);
}
}
class UserController extends \BaseController
{
public function getUser()
{
$user = UserModel::with('posts')->find(1);
return DTO::make($user)->only(['id', 'firstname', 'posts.id', 'posts.body']);
or
return DTO::make($user)->except(['lastname', 'posts.body']);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.