Download the PHP package yorcreative/laravel-argonaut-dto without Composer

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

Laravel Argonaut DTO

GitHub license GitHub stars GitHub Org's stars GitHub issues GitHub forks PHPUnit

Laravel Argonaut DTO is a lightweight, highly composable package for transforming arrays, objects, or collections into structured DTOs (Data Transfer Objects), with built-in support for:


📦 Installation

Install via Composer:


🚀 Quick Start

1. Define a DTO

DTOs extend ArgonautDTO, and define your expected structure via public properties, casting rules, and validation.

This defines a strongly typed DTO with both validation rules and simple type casting.


2. Create an Assembler

Assemblers are responsible for mapping raw inputs (arrays or objects) into your DTOs.

Assembler method names must follow the format to<ClassName> or from<ClassName>, and are resolved automatically using class_basename.


3. Assemble a DTO

Use the assembler to transform raw data into structured, casted DTO instances.

You can also batch transform arrays or collections:


🧪 Real-World Static Usage Example: Product + Features + Reviews

This example demonstrates nested relationships and complex type casting in action.

ProductDTO with nested casting:

ProductDTOAssembler mapping input structure:

🎯 Advanced: Dependency Injection in Assemblers

ArgonautAssembler offers enhanced flexibility for your Assembler logic by supporting dependency injection. This allows you to leverage services or custom logic, whether defined in static or non-static methods, during the DTO assembly process. This is particularly powerful when integrating with Laravel's service container.

This feature enables you to:

How Dependency Injection Works

ArgonautAssembler supports dependency injection in non-static transformation methods (e.g., toUserDTO or fromUserDTO) by leveraging Laravel’s service container. When you call ArgonautAssembler::assemble(), fromCollection(), fromArray(), or assembleInstance() with an instance of the assembler, the transformation method is invoked on that instance. Laravel’s container automatically resolves and injects any dependencies declared in the method’s signature.

Example: Using Dependency Injection

Below is an example of an assembler with a non-static transformation method that uses dependency injection to format a user’s name via an injected service.

Registering the Assembler

Using the Assembler

To use the assembler with dependency injection, you need to provide an instance of the assembler to the assemble method or related methods (fromCollection, fromArray, or assembleInstance). Laravel’s container will resolve the dependencies when the method is invoked.

In this example:


Advanced: 🎯 DTOs with Prioritized Attributes and Custom Setters

ArgonautDTO allows you to prioritize the assignment of specific fields using $prioritizedAttributes, which is critical for cases where one field influences others.


🔁 Casting Reference

Casting allows you to automatically transform values into other DTOs, Laravel Collections, arrays, dates, and more.

Cast Type Example Description
Scalar 'string', 'int', etc. Native PHP type cast
Single DTO ProfileDTO::class Cast an array to a DTO instance
Array of DTOs [RoleDTO::class] Cast to array of DTOs
Collection of DTOs Collection::class . ':' . CommentDTO::class Cast to a Laravel Collection
Date casting Carbon::class Cast to Carbon/DateTime instance

✅ Validation

Validate DTOs with Laravel’s validator:


📤 Serialization

Serialize DTOs for output, API responses, etc.


🛠️ DTO Collection Helper

Create DTO collections directly:


🧪 Testing

Run the test suite using:


📚 Credits


📃 License

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


All versions of laravel-argonaut-dto with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3|^8.4
illuminate/contracts 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 yorcreative/laravel-argonaut-dto contains the following files

Loading the files please wait ....