2017 © Pedro Peláez
 

library dto

PHP DTO

image

carousel/dto

PHP DTO

  • Sunday, March 18, 2018
  • by miro
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 6 % Grown

The README.md

Simple DTO implementation in PHP (single process)

author: miroslav.trninic@gmail.com, (*1)

Introduction

This small utility library is acting like real DTO object, that lives between two processes, but in PHP environment. It can be injected into controller or in some kind of middleware. It has couple of handy helper functions like camelize, only, except that converts input into more granular form., (*2)

Usage:

shell of composer.json, (*3)

composer require carousel/dto, (*4)

<?php

use Carousel\DTO\DTOClass;

//mock request data (array)
$request = [
    'myUsername' => 'John Scofield',
    'my_timezone' => 'UTC+1'
];

//inject DTO in controller or middleware
public function __construct($request)
{
    $this->dto = new DTOClass($request);
}

//camelize input key
$camelized = $this->dto->camelize('my_timezone');

//camelize all input keys
$camelized = $this->dto->camelize();

//exclude data from input
$except = $this->dto->except(['myUsername']);

//get only subset of data from input
$only = $this->dto->only(['myUsername']);

//serialize input
$serialized = $this->dto->serialize();

//decamelize all request keys in DTO object
$request = $dto->decamelize();
$dto->request = $request;
//return one decamelized key
return json_encode($dto->my_username);

The Versions

18/03 2018

dev-master

9999999-dev https://github.com/carousel/dto

PHP DTO

  Sources   Download

MIT

The Requires

  • php ~7.0|~7.2

 

The Development Requires

dto carousel

18/03 2018

dev-dev

dev-dev https://github.com/carousel/dto

PHP DTO

  Sources   Download

MIT

The Requires

  • php ~7.0|~7.2

 

The Development Requires

dto carousel

18/03 2018

1.0.3

1.0.3.0 https://github.com/carousel/dto

PHP DTO

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.2

 

The Development Requires

dto carousel

17/03 2018

v1.0.2

1.0.2.0 https://github.com/carousel/dto

PHP DTO

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

dto carousel

17/03 2018

v1.0.1

1.0.1.0 https://github.com/carousel/DTO

PHP DTO

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

dto carousel

17/03 2018

v1.0.0

1.0.0.0 https://github.com/carousel/DTO

PHP DTO

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

dto carousel