Download the PHP package guyliangilsing/php-class-mapper without Composer
On this page you can find all versions of the php package guyliangilsing/php-class-mapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download guyliangilsing/php-class-mapper
More information about guyliangilsing/php-class-mapper
Files in guyliangilsing/php-class-mapper
Package php-class-mapper
Short Description A simple package that provides you with a simple class mapping system.
License MIT
Informations about the package php-class-mapper
PHPClassMapper
A simple package that provides you with a simple class mapping system.
Table of Contents
- PHPClassMapper
- Table of Contents
- Features
- Installation
- usage
- Class to class mapping
- Configuring the mapper
- Creating a mapping
- Creating the mapper
- Using the mapper
- Array mapping
- Configuring the mapper
- Creating a mapping
- Creating the mapper
- Using the mapper
- Class to class mapping
- Dependency injection containers
Features
PHPClassMapper comes with the following features:
- Class to class mapping
- Array to class mapping
- Class to array mapping
Installation
usage
Class to class mapping
Configuring the mapper
You need to supply a configuration class before you can create the mapper class. You can create a configuration as follows:
In this configuration you can add a mapping with the following code:
Creating a mapping
To let the mapper know how to map your classes, you need to provide it with a mapping. A mapping can be created as follows:
Creating the mapper
Once you have your configuration, you can instantiate a mapper:
Using the mapper
Once you have the mapper instantiated, you can use it in the following way:
Array mapping
Configuring the mapper
You need to supply a configuration class before you can create the mapper class. You can create a configuration as follows:
In this configuration you can add two different mapping types:
- To array mapping (class -> array)
- From array mapping (array -> class)
To array mapping
From array mapping
Creating a mapping
Since you can map arrays in two different ways, two different interfaces are being used:
- ToArrayMappingInterface
- FromArrayMappingInterface
To array mapping
From array mapping
Creating the mapper
Once you have your configuration, you can instantiate a mapper:
Using the mapper
Once you have the mapper instantiated, you can use it in the following way:
Dependency injection containers
You can register the mapper with your favorite dependency injection container by using the MapperInterface
and MapperConfigurationInterface
interfaces.