Download the PHP package ccharz/laravel-dto-lite without Composer

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

Laravel Data Transfer Object Lite

This is a basic implementation of the data transfer object (DTO) concept. The idea is to describe input and output of data in one simple basic php class file. It is meant to replace FormRequests and Resources and can also be used to automatically generate typescript definitions.

This package is similar to the Laravel Data Package from Spatie. The main difference it contains no reflection class magic and only provides the basic functionalities.

Installation

Usage

Example DTO

Casts

Casts for attributes can be defined similar to eloquent casts. It is also possible to define casts to an array

Validation

If a rules method exists, validation is automatically performed when creating a DTO from a request manually or by automatic dependency injection.

You can also inject the rules from casts in your rules:

Automatic Injection

With the help if laravels dependency injection, the dto can be used in a controller method function and is automatically filled with the validated input data from the request.

Eloquent Castable

DataTransferObjects can be used as a cast in eloquent models

If the column is nullable, you have to append the cast parameter "nullable":

Response

Data Transfer Objects are automatically converted to an response if returned from a controller

You can also return a resource collection of data transfer objects

Map to DTO Array

An array can automatically be mapped to an array of the DTO:

Typescript Definitions

You can use https://github.com/spatie/laravel-typescript-transformer to automatically generate typescript definitions for your Data Transfer Objects and Enums.

generates to the following typescript definition:

Artisan Command

To create a new data transfer object, use the make:dto Artisan command:


All versions of laravel-dto-lite with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^10.0|^11.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 ccharz/laravel-dto-lite contains the following files

Loading the files please wait ....