Download the PHP package emulgeator/array-to-class-mapper without Composer

On this page you can find all versions of the php package emulgeator/array-to-class-mapper. 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 array-to-class-mapper

Array to Class Mapper

A simple library which automatically maps a given multi dimensional array to a given class.

Getting Started

Installing

Run composer require emulgeator/array-to-class-mapper to add this library as a dependency to your project

Usage

Simple scalar type mapping

As you'll see the library casts the values from the given array. So for example: $dto->id will be an integer indeed.

The mapper does that by checking the type of the property. If it's not set it tries to fetch this information from the DocBlock

Class mapping

Complex type mapping

In case of complex types you both DocBlock and type hinting can be used. See the previous example modified to have a series of inner objects:

Defining custom mapper for specific type

If a data mapping is not possible by simply casting the stored value, custom mappers can be set:

The same works if the Custom type is in an array but in this case the mapper function will receive the subarray as is:

Limitations

The library currently is not able to import and auto load a class defined in a DocBlock. The following example will not work because the class is not imported neither we know the FQCN:

To fix this you need to use the FQCN of the class:


All versions of array-to-class-mapper with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 emulgeator/array-to-class-mapper contains the following files

Loading the files please wait ....