Download the PHP package andrepolo/lara-dto without Composer

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

lara-dto

Add data transfer objects to your Laravel app to transfer structured data

Installation

To install the package to your laravel app, just require it using composer:

To modify the config file, for example to change the default namespace of your data transfer item classes, you can eighter use the artisan command:

or use the command that comes with the package:

After executing this you will find a new config file in your app/config directory: datatransfer.php

Creating Items and Collections

Creating a DataTransferItem class

The recommended way is to use the artisan command that ships with this package:

This command will create a new DataTransferItem with the given name and store it in the namespace which is defined in the config file datatransfer.php in the namespace section. If you pass a name like this Subfolder\\NestedItem, the class NestedItem will be stored in the folder Subfolder under the namespace. By default the namespace is App\DataTransfer. The command takes care if a class with the same name already exists in your directory. To force the command to overwrite this existing class (which is most unlikely in most cases) you can add the -f option in the make command. This is how this class would look like if you used the name MyFirstDatatransferItem:

Another way is to simply create a new class by coppying the above example. This class has to extend AndrePolo\LaraDto\DataTransferItem

Create a new Instance of a datatransfer class

Creating a DataTransferCollection class

Also, use the command from this package:

This command is creating a DataTransferCollection with the given name. Here you have the option -f again to force the command to create the new class. Every DataTransferCollection contains a list of DataTransferItems. You can automatically create the corresponding DataTransferItem by using the -i or --item option. With this option set the command creates an item with the same name as the collection but with the suffix Item.

For example if you pass the name MyFirstDatatransfer, a item with the name MyFirstDatatransferItem is created. Same if you pass MyFirstDatatransferCollection as the name

This is how the class would look like:

Usage

You can fill it by passing the data directly to the constructor:

or just new it up and then call the fromArray method:

Using this method fills all matching properties with the given values. The most important feature of this method is it automatically fills all nested instances of DataTransferItem or DataTransferCollection.

Setter and Getter

If you have a setter method defined for your property it will be automatically used in the fromArray method. You can overwrite this behavior globally
by set the config var use_setter to false or for a specific class by overwriting the useSetter method.

For getter methods it is working the same way as described above.

Strict mode

This is disabled by default. You can enable it globally by setting it to true in the config file. This option indicates whether filling items from array or json should only be possible when the corresponding values match to what is defined in the doc block. See config file for more information.

Schema

Mostly your data-transfer-objects will be nested structures. Therefore it might be usefull to quickly share a schema of your DTO to somebody you work with. You can call the schema method on your object to recieve the properties as an array. When you use the jsonSchema method, it will be a json object.


All versions of lara-dto with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2.5
illuminate/support Version ^7.4
kamermans/docblock-reflection Version ^1.0
ext-json Version *
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 andrepolo/lara-dto contains the following files

Loading the files please wait ....