Download the PHP package neuron-php/dto without Composer

On this page you can find all versions of the php package neuron-php/dto. 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 dto

CI codecov

Neuron-PHP DTO

A powerful Data Transfer Object (DTO) library for PHP 8.4+ that provides dynamic DTO creation, comprehensive validation, and flexible data mapping capabilities with support for nested structures and YAML configuration.

Table of Contents

Installation

Requirements

Install via Composer

Quick Start

1. Define Your DTO Structure

Create a YAML configuration file (user.yaml):

2. Create and Use the DTO

Core Features

DTO Configuration

Basic Structure

DTOs are configured using YAML files with property definitions:

Complete Example

Creating DTOs

From YAML Configuration

Programmatic Creation

Nested Objects

DTO Composition (Reusable DTOs)

You can create reusable DTO definitions and reference them in other DTOs, making it easy to share common structures like timestamps, addresses, or user records across multiple DTOs.

Creating Reusable DTOs

First, create standalone DTO definition files:

common/timestamps.yaml

common/address.yaml

common/user.yaml

Using Referenced DTOs

Reference these DTOs in your main DTO definition using type: dto with a ref parameter:

Working with Composed DTOs

Benefits of DTO Composition

Path Resolution

Referenced paths are resolved relative to the parent DTO file:

Validation

Built-in Validators

The DTO component includes comprehensive validation for each property type:

Validation Rules

Length Validation

Range Validation

Pattern Validation

Enum Validation

Custom Validation

Data Mapping

Mapper Configuration

Create a mapping configuration (mapping.yaml):

Using the Mapper

Dynamic Mapping

Property Types

Supported Types

Type Description Validation
string Text values Length, pattern
integer Whole numbers Range, min, max
float Decimal numbers Range, precision
boolean True/false values Type checking
array Lists of items Item validation
object Nested objects Property validation
dto Referenced DTO Full DTO validation
email Email addresses RFC compliance
url URLs URL format
date Date values Date format
date_time Date and time DateTime format
time Time values Time format
currency Money amounts Currency format
uuid UUIDs UUID v4 format
ip_address IP addresses IPv4/IPv6
phone_number Phone numbers International format
name Person names Name validation
ein EIN numbers US EIN format
upc UPC codes UPC-A format
numeric Any number Numeric validation
image Image data Base64/data URI, MIME type
base64 Base64 encoded data Base64 format

Type Examples

Collections

Array of Objects

Array of Primitives

Advanced Usage

Working with Images

The image type provides validation for base64-encoded image data and data URIs. It supports common image formats including JPEG, PNG, GIF, WebP, and SVG.

Image Property Configuration

Using Image Properties in Code

Supported Image Formats

The image validator automatically detects and validates the following formats:

Image Validation Features

Security Considerations for SVG

SVG images are disabled by default because they are XML-based and can contain:

If you need to accept SVG images, you must:

  1. Explicitly enable SVG support in your validator configuration
  2. Sanitize SVG content before storage or display
  3. Serve SVG files with appropriate Content Security Policy headers
  4. Consider using a dedicated SVG sanitization library

To enable SVG support (use with caution):

Complex DTO Example

Custom DTO Class

DTO Factory with Caching

Testing

Unit Testing DTOs

Testing Mappers

Best Practices

DTO Design

Validation Strategy

Error Handling

Reusable DTOs

Performance Optimization

Integration Examples

API Request Validation

Database Integration

More Information

License

MIT License - see LICENSE file for details


All versions of dto with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
symfony/yaml Version ^6.4
neuron-php/validation Version ^0.7.0
neuron-php/logging Version 0.9.*
myclabs/deep-copy Version ^1.12
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 neuron-php/dto contains the following files

Loading the files please wait ...