Download the PHP package tuxonice/transfer-objects without Composer

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

Bare simple data transfer object

Build Status Total Downloads Latest Stable Version License

In the ever-evolving landscape of software development, efficient and structured data communication is paramount. DTO package is designed to streamline and enhance the way data is transferred between different layers of your application, promoting clarity, maintainability, and robustness.

Whether you're building a RESTful API, a microservices architecture, or a traditional web application, Data Transfer Objects package empowers you to manage data flow with elegance and precision. Elevate your code quality and simplify your data handling processes with our intuitive and developer-friendly DTO solution.

Installation

You can install the package via composer:

Setup

The goal of this package is to create data transfer objects from json definitions as easy as possible.

  1. In your project create a folder to hold on the definition files.

  2. Create a folder to hold on the generated data transfer objects

  3. Create a command to generate the DTO's. If you are using symfony console could be something like:

  4. For Laravel projects:

  5. Define the dto through the definition file

This definition will generate the following transfer class:

Usage

Creating and set data

Get data

Creating from array

When creating from array its possible to use both camelCase or snake_case as array keys

Export to array

will return:

The toArray() method has two parameters

will return:

will return:

Create definition file(s)

You can define one or more transfer objects definitions for each json file. Start by creating a json object that will contain your definitions:

and inside the transfers array define your transfer:

Available fields

Field Type Required Default Description
name string yes -- The transfer object name. The result class name will be this name concatenated with "Transfer". E.g. CustomerTransfer
properties array yes -- An array of objects with definition of each class property
immutable bool no false Remove setters from the class. In this case the class name will end with "TransferImmutable"
deprecationDescription string no "" If present and not empty, will add an annotation with @deprecated, to mark this class as deprecated
Field Type Required Default Description
name string yes -- field name in camelCase
type string yes -- The field type. Can be a native type (string, int, float, bool), or any other class. If the type ends with [], will mark the property as an array
deprecationDescription string no "" If present and with a text, will add an annotation with @deprecated, to mark this field as deprecated
nullable bool no false Set if the property can be null. Can not be set to true when the type is an array
namespace string yes if the type is another class -- Namespace for the class in case the property type is another class (except another transfer object)
singular string yes if the type is an array -- Singular form of the property if the type is an array

Example of property definitions

License

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


All versions of transfer-objects with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-json Version *
twig/twig Version ^3.5
opis/json-schema Version ^2.3
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 tuxonice/transfer-objects contains the following files

Loading the files please wait ....