Download the PHP package cmath10/mapper without Composer

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

Mapper

The library provides a utility for converting objects to each other (and arrays to objects) and transferring data between them by reusable map.

Basic example:

How it works

The main term of the library is a map. It is an object which is containing information about how to extract values from the source and inject them into a destination object. Values can be processed before injection (to get an opportunity for sanitization and nested mapping).

Map includes:

By default, a map creates a set of accessors based on a class properties list, so a field from a source will be mapped on a field of a destination with the same name. You can change this behavior for specific fields if needed.

All maps must be registered in a mapper instance before using. When you call the mapper method map it seeks the correct map for a given source and destination, then it uses accessors to extract values, filters to process them, and, after that, injects values to a destination. If the destination is a class name, the mapper will try to create an instance of the given class, if the class constructor is public and all possible arguments are optional.

Installation

API

cmath10\Mapper\MapperInterface — interface for mappers:

cmath10\mapper\MapInterface — interface for maps:

cmath10\mapper\FieldAccessor\AccessorInterface — interface for accessors:

cmath10\mapper\FieldFilter\FitlerInterface — interface for filters:

cmath10\Mapper\TypeFilterInterface — interface for type filters is used to process type names. Useful for extracting class names from runtime generated classes like proxies in Doctrine. Used in default mapper which uses an array of type filters as a constructor parameter (to instantiate cmath10\mapper\TypeGuesser which is used to determine the correct map for supplied types in mapper's map method).

Available maps

AbstractMap

Basic class is used to create custom map classes, implements MapperInterface; provides following protected method:

Usage example:

DefaultMap

Simple descendant of AbstractMap, just calls setupDefaults in its constructor; the mapper create method creates, registers and returns instance of this class.

Available accessors

ClosureAccessor

Uses callback to extract a value:

ExpressionAccessor

Uses symfony/expression-language to extract a value:

PresetAccessor

Does not extract a value, just provides:

PropertyPathAccessor

Uses symfony/property-access to extract a value. This accessor is used by default. Calls like:

and

are equivalent. Also, if the fields in a source and destination have the same name, and you use setupDefaults, you don't need to call route or forMember explicitly.

Available filters

ClosureFilter

Uses callback to process value:

IfNullFilter

Replaces the value if it is null:

AbstractMappingFilter

Basic class for filters that can use mapper. Requires class name in the constructor. Used for nested mapping.

ObjectMappingFilter

Descendant of AbstractMappingFilter, uses class name and mapper to make an object from a source member:

ObjectArrayMappingFilter

Descendant of AbstractMappingFilter, uses class name and mapper to make an array of objects from a source member, if the source member's value is array (returns an empty array instead):


All versions of mapper with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
symfony/property-access Version ^4.4 || ^5.0
symfony/expression-language Version ^4.4 || ^5.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 cmath10/mapper contains the following files

Loading the files please wait ....