Download the PHP package enm/transformer-bundle without Composer

On this page you can find all versions of the php package enm/transformer-bundle. 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 transformer-bundle

This Bundle isn't maintained anymore!

Enm / TransformerBundle BuildStatus

SensioLabsInsight

What can the bundle be used for?

This Bundle is used to integrate the Enm/Transformer library into a Symfony2 environment.

The Library can be used for validating an array, an object or a json-string and get an array, an object or a json-string back with the validated values.

This will be useful for example with a REST-API. You could give a JSON string in and out and the transformer can secure that all values are valid.

Basic Usage

The Transformer is reachable through a symfony service.

enm.transformer

For the auto-complete the "TransformerInterface" can be used for typification:

__construct(\Enm\TransformerBundle\Interfaces\TransformerInterface $transformer){
  $this->transformer = $transformer;
}

The Interface will offer different Methods to you:

Method: transform()

This method will validate the given values and build the result from the correct values (including property renaming, value normalizing and value converting if configured).

Parameters:

Result:

Method: reverseTransform()

This method returns the values of the object in the original structure (original naming before the transformation), but in the chosen format (object or array or json)

Parameters:

Result:

Method: getEmptyObjectStructureFromConfig()

This Method will build a structure of the needed object from your configuration array.

Parameters:

Result:

Method: convert()

This value will convert an object, an array or a json string to a standard object, an array or a json string.

Parameters:

Result:

Validation

For validation you can use a configuration array, which have to be given to the transform or reverseTransform method.

The config array has some parameters for all types of validation and some special type validation parameters.

Some of the parameters are required, some are optional.

The base configuration looks like:

$config = array(
  'key' => array(
    'type' => '', // required
    'renameTo' => '', // optional
    'children' => array(), // only in use with types "object", "collection" and (if you want it) "individual"
    'options' => array() // optional
  )
)

type

This option is the only always required option.

With this option you have to give the data type for validation to the transformer.

Possible Values:

renameTo

This option is optional, but if it is used, it needs a string given.

This option can be used for renaming the key to a different property name.

children

This option is only possible if type is object, collection or individual. If type is object or collection, this option is required.

This option needs a complete configuration array for child elements (see object and collection validation)

Default Options

possible for all types and always optional:

$config['key']['options'] => array(
  'required' => true,
  'requiredIfAvailable' => array(
    'and' => array(), 
    'or' => array()
  ),
  'requiredIfNotAvailable' => array(
    'and' => array(),
    'or' => array()
  ),
  'forbiddenIfAvailable' => array(),
  'forbiddenIfNotAvailable' => array()
)

required

This option needs true or false. Default value is false.

If set to true, this option requires the transformer to validate that the current value is not NULL

requiredIfAvailable

This option have to be an array, which requires a sub configuration if set.

Generally this option tells the transformer to set a current value required.

Sub Configuration:

array(
  'and' => array(),
  'or' => array()
)

requiredIfNotAvailable

This option have to be an array, which requires a sub configuration if set.

Generally this option tells the transformer to set a current value required.

Sub Configuration:

array(
  'and' => array(),
  'or' => array()
)

forbiddenIfAvailable

This option needs an array of config key names.

It requires the transformer to validate that the current key will not have a value or a value equal to NULL if one of the given keys has a value.

forbiddenIfNotAvailable

This option needs an array of config key names.

It requires the transformer to validate that the current key will not have a value or a value equal to NULL if one of the given keys does not have a value.

String Validation

Base configuration:

$config = array(
  'key' => array(
    'type' => 'string',
  )
)

Possible options, all optional:

$config['key']['options'] = array(
  'stringValidation' => '' // email|url|ip
)

All versions of transformer-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
enm/transformer Version 0.*
symfony/config Version ^2.2|^3.0
symfony/dependency-injection Version 2.2|^3.0
symfony/http-kernel Version ^2.2|^3.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 enm/transformer-bundle contains the following files

Loading the files please wait ....