Download the PHP package fedejuret/dto-builder without Composer

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

DTO Builder

DTO Builder is a lightweight PHP library that streamlines the process of creating and populating Data Transfer Objects (DTOs) using PHP 8+ attributes. It enables dynamic property hydration, automatic validation, and conversion to arrays with minimal boilerplate.


โœจ Features


๐Ÿ“ฆ Installation

Install the package via Composer:


๐Ÿš€ Getting Started

1. Define Your DTO

This requires calling setters manually for each property. With DTO Builder, you can simplify this dramatically.


2. Use Attributes for Property Mapping and Validation


๐Ÿงฐ Traits

Loadable

Enables the loadFromArray(array $data): self method, which automatically maps input arrays to DTO properties based on defined attributes.

Arrayable

Adds a toArray(): array method, which serializes the DTO to a key-value array using the attribute-defined property names.


๐Ÿท๏ธ Attributes

#[Property]

Defines mapping behavior for each DTO property.

Attribute Description
name Overrides the array key name for hydration and serialization.
setter Specifies a custom setter method.
getter Specifies a custom getter method.

โœ… Built-in Validations

Use validation attributes to ensure the integrity of your DTO before hydration.

Attribute Description
#[Required] Ensures the value is present in the input.
#[IsString] Must be of type string.
#[IsEmail] Must be a valid email address.
#[IsDate] Must be a valid date string.
#[IsBoolean] Must be a boolean (true/false).
#[IsNumeric] Must be numeric.
#[IsInteger] Must be an integer.
#[IsDouble] Must be a double/float.
#[IsArray] Must be an array.
#[IsDomain] Must be a valid domain name.
#[IsIPAddress] Must be a valid IP address.
#[Length(min, max)] Validates the string length.
#[IsIn(availableValues)] Validates if value is in array.
#[IsRegex(pattern)] Validates if values match with regex.
#[IsUuid] Validates if values is a valid UUID.

๐Ÿงผ Built-in Sanitizations

DTO Builder allows you to sanitize each property before validation and usage.

#[HtmlSanitization]

Removes all HTML tags from a string, while optionally keeping specific safe tags.

#[SecureSanitization]

A defensive sanitization designed to help mitigate OWASP Top 10 vulnerabilities like XSS.


๐Ÿ› ๏ธ Custom Sanitizations

You can create your own sanitizers by implementing the SanitizationInterface and marking them as attributes.

Usage:

Custom sanitizations allow you to apply reusable transformations to your data before validation or further processing.


๐Ÿฅช Running Tests

Clone the repository and install dependencies:


๐Ÿค Contributing

Contributions are welcome! To get started:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -m 'Add new feature')
  4. Push to the branch (git push origin feature/your-feature)
  5. Open a Pull Request

Please follow the PSR-12 coding standard when contributing.


๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for more information.


๐Ÿ“ข Contact


All versions of dto-builder with dependencies

PHP Build Version
Package Version
No informations.
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 fedejuret/dto-builder contains the following files

Loading the files please wait ....