Download the PHP package olexin-pro/data-transfer-object without Composer

On this page you can find all versions of the php package olexin-pro/data-transfer-object. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package data-transfer-object

๐Ÿ“˜ Data Transfer Object

Latest Version on Packagist PHP Version License Tests

A powerful, strict, and production-ready DTO layer for PHP/Laravel.

This package provides automatic type conversion, PHP 8 Attribute mapping, nested DTO support, Laravel Casts, and seamless integration with API Resources. It ensures your data is validated, normalized, and strongly typed from the moment it enters your application.

โœจ Features


Table of Contents


๐Ÿ“ฆ Installation

Requires PHP 8.3+

`


๐Ÿš€ Quick Start

1. Define your DTO

Create a class extending AbstractDTO and use attributes to define fields.

2. Use it


๐ŸŽฏ Usage Guide

Manual Instantiation

You can instantiate a DTO with any iterable (array or collection). Keys are automatically normalized from camelCase to snake_case during processing.

Nested DTOs

Complex structures are handled automatically. Simply typehint the property with another DTO class and use TypeEnum::DTO.

Input:

Result: $dto->profile is an instance of ProfileDTO.


๐Ÿ“ฅ Laravel Integration

Request Injection

The package integrates seamlessly with Laravel's Service Container. You can typehint a DTO in your Controller method, and it will automatically hydrate from the current Request (supporting JSON, Form Data, Query Params).

Alternatively, use fromRequest:

Model Casts

Store DTOs directly in your database using Laravel's Custom Casts. The DTO is serialized to JSON on save and hydrated back to a DTO on retrieval.

In your Model:

Usage:

API Resources

DTOs implement Arrayable, making them compatible with Laravel API Resources.


๐Ÿงฐ Reference

Supported Types (TypeEnum)

The #[Field] attribute requires a type definition from TypeEnum.

Enum Case Description
TypeEnum::INT Casts to integer
TypeEnum::FLOAT Casts to float
TypeEnum::STRING Casts to string
TypeEnum::BOOLEAN Casts to boolean
TypeEnum::ARRAY Casts to array
TypeEnum::DATE Handles date strings
TypeEnum::DTO Hydrates a nested DTO
TypeEnum::COLLECTION Hydrates a collection of DTOs/items
TypeEnum::DYNAMIC No casting, keeps original type

๐Ÿง  Architecture & Principles

  1. Immutability: DTOs are designed to be immutable after instantiation.
  2. Safety: Internal fields (_raw, etc.) are hidden.
  3. Normalization: Input keys are normalized (snake_case/camelCase handling).
  4. Performance: Reflection metadata is cached to ensure production speed.

๐Ÿงช Testing

Run the full test suite:


๐Ÿ“ License

This package is open-sourced software licensed under the MIT license.


All versions of data-transfer-object with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/support Version ^10.0 || ^11.0 || ^12.0
illuminate/contracts Version ^10.0 || ^11.0 || ^12.0
illuminate/collections Version ^10.0 || ^11.0 || ^12.0
illuminate/database Version ^10.0 || ^11.0 || ^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package olexin-pro/data-transfer-object contains the following files

Loading the files please wait ...