Download the PHP package fab2s/laravel-dt0 without Composer
On this page you can find all versions of the php package fab2s/laravel-dt0. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fab2s/laravel-dt0
More information about fab2s/laravel-dt0
Files in fab2s/laravel-dt0
Package laravel-dt0
Short Description Laravel support for fab2s/dt0
License MIT
Homepage https://github.com/fab2s/laravel-dt0
Informations about the package laravel-dt0
Laravel Dt0
Laravel support for fab2s/dt0, a DTO (Data-Transfer-Object) PHP implementation that can both secure mutability and implement convenient ways to take control over input and output in various formats.
Installation
Dt0
can be installed using composer:
Usage
Laravel Dt0
only adds Validation implementation and model attribute casting to Dt0
. All other features will work exactly the same. Have a look at Dt0
to find out more.
Caster
In addition to Dt0 casters
, Laravel Dt0
adds a CollectionOfCaster
which can be used to strongly type a Laravel Collection
:
``
It can be used as an inspiration to cast into more types.
Validation
Laravel Dt0
is able to leverage the full power of Laravel validation on each of its public properties. The validation is performed on the input data prior to any property casting or instantiation.
Laravel Dt0
comes with a laravel validation.
To use it on any Dt0
, just add the Validate
class attribute :
``
Rules can be added in three ways:
-
using the second argument of the
Validate
class attribute:``
-
using the
Rules
class attribute:``
-
using the
Rule
property attribute:``
Combo of the above three are permitted as illustrated in ValidatableDt0
.
In case of redundancy, priority will be first in
Validate
,Rules
thenRule
. Dt0 has no opinion of the method used to define rules. They will all perform the same as they are compiled once per process and kept ready for any reuse.
Validation is performed using withValidation
method:
Model Attribute casting
Should you want to use a Dt0
as a Laravel Model attribute, you can directly cast it as your Dt0
thanks to the generic cast Dt0Cast
.
Only requirement is for your Dt0 to extend fab2s\Dt0\Laravel\LaravelDt0Trait
.
``
Requirements
Dt0
is tested against php 8.1 and 8.2 and Laravel 10 / 11
Contributing
Contributions are welcome, do not hesitate to open issues and submit pull requests.
License
Dt0
is open-sourced software licensed under the MIT license.
All versions of laravel-dt0 with dependencies
fab2s/dt0 Version ^0.0.1
illuminate/translation Version ^10.0|^11.0
illuminate/validation Version ^10.0|^11.0