Universal Data Transport Objects
Installs: 30 325
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- ext-json: *
- tightenco/collect: ^5.7
Requires (Dev)
- carbondate/carbon: ^2.0@dev
- fzaninotto/faker: ^1.6
- phpunit/phpunit: ^5.3
README
Installation
php composer require framespictures/dto
Note
PLEASE NOTE THIS PROJECT IS WORK IN PROGRESS! API MAY CHANGE WITHOUT WARNING!
IF YOU WANT TO INCORPORATE IT INTO YOUR PROJECT PLEASE STICK TO ONE PARTICULAR VERSION.
Data Transfer Object Theory
A Data Transfer Object is an object that is used to encapsulate data, and send it from one subsystem of an application to another. DTOs are most commonly used by the Services layer in an N-Tier application to transfer data between itself and the UI layer. The main benefit here is that it reduces the amount of data that needs to be sent across the wire in distributed applications. They also make great models in the MVC pattern.
Another use for DTOs can be to encapsulate parameters for method calls. This can be useful if a method takes more than 4 or 5 parameters.
Using DTOs internally vastly simplifies PHP code allowing for IDE code hinting and avoiding mistakes in array string keys which is a common source of errors. It also greatly improves refactoring.
Using it in Repository Pattern in conjunction with Eloquent, allows for true logic and persistence separation.