Download the PHP package shipmonk/input-mapper without Composer

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

ShipMonk Input Mapper

High performance input mapper for PHP with support for generics, array shapes and nullable types. For each input class, a mapper is generated at runtime and cached on disk. The mapper is generated only once and then reused on subsequent requests. The generated mapper is highly optimized for performance and it is designed to be human readable. You can see example of generated mappers in the tests directory.

Installation:

Features

Built-in mappers

Input Mapper comes with built-in mappers for the following types:

You can write your own mappers or replace the default mappers with your own.

Built-in validators

Input Mapper comes with some built-in validators:

You can write your own validators if you need more.

Usage:

Write Input Class

To use Input Mapper, write a class with a public constructor and add either native or PHPDoc types to all constructor parameters.

Optional fields can either be marked with #[Optional] attribute (allowing you to specify a default value), or if you need to distinguish between default and missing values, you can wrap the type with ShipMonk\InputMapper\Runtime\Optional class.

By default, any extra properties are not allowed. You can change that by adding #[AllowExtraKeys] over the class.

Map Input

To map input, provide a path to a writable directory where generated mappers will be stored.

It's important to set $autoRefresh to false in production to avoid recompiling mappers on every request.

Adding Validation Rules

You can add validation rules by adding attributes to constructor parameters.

For example, to validate that age is between 18 and 99, you can add the AssertIntRange attribute to the constructor parameter:

Renaming keys

If the input keys do not match the property names, you can use the #[SourceKey] attribute to specify the key name:

Parsing polymorphic classes (subtypes with a common parent)

If you need to parse a hierarchy of classes, you can use the #[Discriminator] attribute. (The discriminator field does not need to be mapped to a property if #[AllowExtraKeys] is used.)

or, with enum:

Using custom mappers

To map classes with your custom mapper, you need to implement ShipMonk\InputMapper\Runtime\Mapper interface and register it with MapperProvider:

Customizing default mappers inferred from types

To customize how default mappers are inferred from types, you need to implement

Then register your factory provider with MapperProvider:

Contributing


All versions of input-mapper with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
nette/utils Version ^3.2 || ^4.0
nikic/php-parser Version ^5.0
phpstan/phpdoc-parser Version ^2.0.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 shipmonk/input-mapper contains the following files

Loading the files please wait ....