Download the PHP package atwinta/data-transfer-object without Composer

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

Data Transfer Object Package

Установка

Установка через Composer:

Использование

Создание DTO

php artisan make:dto <name> - создаст класс в папке app/DTO

После создания, в DTO нужно будет указать поля. Рекомендуется указывать их в конструкторе, потому что поля, указанные в конструкторе можно заполнить используя метод DTO::create() и сделать обязательными для создания DTO.

Для уменьшения количества кода рекомендуется определять поля в конструкторе:

Использование DTO

Для создания DTO можно напрямую использовать конструктор или использовать метод DTO::create(). Этот метод принимает массив вида [название поля => значение] и самостоятельно вызывает конструктор, передавая значения в нужном порядке. Если передать в него объект, он будет приведён к массиву следующим образом:

Так как базовый класс DTO имплементирует интерфейс \Illuminate\Contracts\Support\Arrayable, DTO можно заполнить из других DTO никак не изменяя их перед передачей в DTO::create().

Для массового заполнения уже созданного DTO можно использовать метод DTO::fill(). Он принимает те же параметры, что и DTO::create(), и обрабатывает их тем же образом.

По умолчанию, DTO::create() и DTO::fill() клонируют объекты перед записью в поля заполняемого DTO. Чтобы отключить клонирование, нужно передать false во второй параметр этих методов.


All versions of data-transfer-object with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
laravel/framework Version ^9.0|^10.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 atwinta/data-transfer-object contains the following files

Loading the files please wait ....