Download the PHP package holiq/action-data without Composer

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

Laravel Action Data

Latest Version on Packagist Total Downloads License

A Laravel package that provides an elegant way to generate and use Actions and Data Transfer Objects (DTOs) in your Laravel projects. This package promotes clean architecture by separating business logic into reusable Action classes and ensuring type-safe data handling with DTOs.

Table of Contents

Features

Requirements

Installation

You can install the package via Composer:

The package will automatically register its service provider.

Optionally, you can publish the configuration file:

After publishing, you can customize the paths in config/action-data.php:

Quick Start

  1. Generate an Action with DTO:

  2. Define your DTO with validation:

  3. Implement your Action:

  4. Use in your controller:

Configuration

After publishing the configuration file, you can customize the paths where Actions and DTOs are generated:

Usage

Generating Actions

Generate Actions using the Artisan command with various options:

Basic Action structure:

Action with DTO parameter:

Generating DTOs

Generate DTOs using the Artisan command:

Generated DTO structure:

Working with DTOs

Creating and Resolving DTOs

DTOs can be created from various data sources:

Array Conversion

Convert DTOs to arrays with different formatting options:

Property Exclusion

Control which properties are included in specific contexts:

Validation

Laravel Action Data provides powerful validation through PHP attributes and custom callbacks.

Attribute-Based Validation

Use PHP attributes for declarative validation rules:

Available validation attributes:

Custom Validation Callbacks

Use custom validation logic with chainable callbacks:

Custom Validation Attributes

You can create your own PHP attributes by implementing Holiq\ActionData\Contracts\Validator:

Nested DTOs

Laravel Action Data automatically resolves nested DTOs and arrays of DTOs:

Simple Nested DTOs

Arrays of DTOs

Data Transformations

Apply automatic data transformations during DTO resolution to clean and format your data:

Complex transformations example:

Real-world Examples

Complete User Management with Validation

When validation fails, Laravel will automatically convert the ValidationException to a standard 422 Unprocessable Entity response.

Nested DTOs Example: Order Management

Advanced Example with Service Dependencies

API Reference

Action Class

resolve(array $parameters = []): static

Resolves an Action instance from Laravel's container with optional parameters.

DataTransferObject Class

Core Methods

resolve(array $data): static
Creates a DTO instance from an array with automatic key transformation and data transformations.

resolveFrom(FormRequest|Model|array $abstract): static
Creates a DTO instance from various data sources.

Array Conversion

toArray(): array - Converts to snake_case array
toCamelCase(): array - Converts to camelCase array
toArrayForCreate(): array - Excludes properties from toExcludedPropertiesOnCreate()
toArrayForUpdate(): array - Excludes properties from toExcludedPropertiesOnUpdate()
toJson(int $options = 0): string - Converts to JSON string toCamelJson(int $options = 0): string - Converts to camelCase JSON string

Validation

validate(callable $validator, string $message): static
Validates using a custom callback.

validateAttributes(): static
Validates using PHP attributes.

Property Access

has(string $property): bool - Checks if property exists
get(string $property, mixed $default = null): mixed - Gets property value

Immutable Update Helpers

with(mixed ...$values): static - Returns a cloned DTO with named-argument overrides
withArray(array $overrides): static - Returns a cloned DTO with snake_case/camelCase key overrides
without(string ...$properties): static - Returns a cloned DTO with nullable properties set to null

Utility Methods

clone(): static - Creates a clone
tap(callable $callback): static - Executes callback and returns instance
dump(): static - Dumps data for debugging
dd(): never - Dumps data and dies

Protected Methods (Override in your DTOs)

toExcludedPropertiesOnCreate(): array - Properties to exclude in create context
toExcludedPropertiesOnUpdate(): array - Properties to exclude in update context
transforms(): array - Data transformations for resolve()

Artisan Commands

make:action [name]

Generates a new Action class.

Options:

make:dto [name]

Generates a new Data Transfer Object class.

Options:

Testing

Run the test suite:

Run static analysis:

Run code formatting:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

The MIT License (MIT). Please see License File for more information.


All versions of action-data with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/support Version ^12.0|^13.0
illuminate/console Version ^12.0|^13.0
illuminate/filesystem Version ^12.0|^13.0
illuminate/container Version ^12.0|^13.0
illuminate/validation Version ^12.0|^13.0
cuyz/valinor Version ^2.0
spatie/php-cloneable Version ^1.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 holiq/action-data contains the following files

Loading the files please wait ...