Download the PHP package shureban/laravel-object-mapper without Composer

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

Laravel object mapper

Installation

Require this package with composer using the following command:

Add the following class to the providers array in config/app.php:

You can also publish the config file to change implementations (ie. interface to specific class).

How to use

You have 3 options to use ObjectMapper

Inheritance

Your mapped object (dto) must inheritance from \Shureban\LaravelObjectMapper\MappableObject

Using trait

Your mapped object (dto) must use \Shureban\LaravelObjectMapper\MappableTrait

Delegate mapping to ObjectMapper

Mappable cases

Below you will see cases which you can use for mapping data into your object

Simple types

Box types

Custom types

Array of types

That typo of mapping may be realized only via phpDoc notation

Special cases

Constructor

If your type object has 1 required parameter and value is NOT an array, ObjectMapper will build instance of this type via constructor call If your type object has 0 or more than 1 required parameters, it will throw WrongConstructorParametersNumberException exception

Correct case:

Wrong case:

PhpDoc

PhpDoc type hinting has much more priority than main type.

Setters

If you want to realize your own logic for setting value, you may place setter method in your mapped object This setter should start from set word and been in camelCase notation.

Some words about second parameter $rawData. Value of this parameter depends on method selected for mapping

Readonly parameters

Readonly parameters will always be skipped

Config rewriting

In object_mapper.php config file have been presented all mappable types classes. You have opportunity to rewrite mapping flow or realize you own one.

If you need to create your own type mapping, follow this way:


All versions of laravel-object-mapper with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
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 shureban/laravel-object-mapper contains the following files

Loading the files please wait ....