Download the PHP package brahmic/clientdto without Composer

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

ClientDTO

What does it do?

Using examples

Custom client example

Resource example

Request example

File Request example

Resolved Data Handlers

ClientDTO allows you to register handlers that process resolved data after DTO creation. This provides a flexible way to modify or enhance response data before it's returned to the user.

Basic Usage

Handler Types

Function Handlers:

Class Handlers:

Caching Behavior

Resolved handlers work intelligently with ClientDTO's caching system:

RAW Cache Mode (requestCacheRaw(true)):

DTO Cache Mode (default):

Handler Parameters

All handlers receive two parameters:

Parameter Type Description
$dto mixed The resolved data (DTO object, string, array, etc.)
$request AbstractRequest The original request object with parameters and context

Benefits of Request Object Access

Passing the original request object to handlers provides several key advantages:

1. Conditional Processing Based on Request Type:

2. Access to Request Parameters:

3. Context-Aware Data Enhancement:

4. Request-Specific Validation:

Use Cases

Data Enhancement:

Conditional Processing:

Debug Information:

Human-Readable Labels for DTO Fields

ClientDTO provides automatic transformation of DTO fields into human-readable labeled format, perfect for frontend display and API responses.

Basic Usage

Add labels to DTO properties and enable automatic transformation:

Automatic Transformation

With #[WithLabels(autoTransform: true)], all labeled fields are automatically transformed when converting DTO to array:

Manual Labeled Access

Get labeled data without automatic transformation:

Working with Existing Transformers

Label functionality respects existing #[WithTransformer] attributes:

Frontend Integration Examples

Vue.js Template:

React Component:

Performance and Caching

Label functionality includes intelligent caching for optimal performance:

Cache Management

For rare edge cases, manual cache clearing is available:

Use Cases

API Responses:

Form Generation:

Data Tables:

Property-level WithLabels (Composite DTOs)

For complex DTOs containing other DTOs, you can control labeling behavior at the property level using #[WithLabels] attributes:

Result:

Priority System:

  1. Property-level #[WithLabels] on parent DTO properties (HIGHEST priority)
  2. Class-level #[WithLabels] on child DTO classes
  3. Default behavior (no labels)

Key Features:

⚠️ Thread Safety Note: Property-level WithLabels uses static context and is not thread-safe in async PHP environments (Swoole, ReactPHP).

GroupedRequest - Composite API Calls

ClientDTO provides GroupedRequest functionality to combine multiple API calls into a single logical operation. This is useful when you need data from multiple endpoints to build a complete picture.

Basic GroupedRequest

Composite DTO Structure

Advanced: Data Processing with handle()

For cases where you need to process the collected data before creating the final DTO, use the handle() method:

Analytics DTO

Execution Flow

Standard GroupedRequest:

  1. Execute child requests → HouseInfoDto + HousePassportDto
  2. Collect data into composite DTO → HouseCompleteInfoDto
  3. Return result → HouseCompleteInfoDto

GroupedRequest with handle():

  1. Execute child requests → HouseInfoDto + HousePassportDto
  2. Collect into intermediate DTO → HouseCompleteInfoDto
  3. Call handle() method → Process intermediate data, return array
  4. Create final DTO → HouseAnalyticsDto::from(array)
  5. Return result → HouseAnalyticsDto

Usage Examples

Key Features

⚠️ Performance Note: GroupedRequest executes multiple HTTP requests. Consider API rate limits and use caching when appropriate.

HTTP Request Caching

ClientDTO provides intelligent HTTP request caching with support for both RAW and DTO modes.

Basic Configuration

Caching Methods

Method Description Default
requestCache() Enable HTTP request caching false
requestCacheRaw() Cache raw HTTP responses instead of DTOs false
postIdempotent() Allow POST requests to be cached false
requestCacheTtl(int $seconds) Set cache TTL in seconds null (no limit)
requestCacheSize(int $bytes) Set max cache entry size 1MB

Caching Modes

DTO Caching (default):

RAW Caching:

Per-Request Control

Use the #[Cacheable] attribute to control caching for specific requests:

Cache Behavior

Default Behavior:

Priority Order:

  1. #[Cacheable] attribute on request class
  2. postIdempotent() setting for POST requests
  3. Global requestCache() setting

Cache Management


All versions of clientdto with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/collections Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
spatie/temporary-directory Version ^2.3
spatie/laravel-data Version ^4.13
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 brahmic/clientdto contains the following files

Loading the files please wait ...