Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/softius/cakephp-param-converter

Converts request parameters to objects
https://github.com/softius/cakephp-param-converter

cakephp cakephp-plugin

Last synced: about 1 month ago
JSON representation

Converts request parameters to objects

Awesome Lists containing this project

README

        

# Param Converter

CakePHP v3.x plugin for converting request parameters to objects. These objects replace the original parameters before dispatching the controller action and hence they can be injected as controller method arguments.

Heavily inspired by [Symfony ParamConverter](https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/converters.html)

## Install

Using Composer:

```
composer require softius/cakephp-param-converter
```

You then need to load the plugin. You can use the shell command:

```
bin/cake plugin load ParamConverter
```

## Usage

Adjustments on application level are only necessary if you need to remove or / add new param converters.

### Configuration

By default, the plugin provides and registers converters that can be used to convert request parameters to Entity and DateTime instances as well as various scalar types.
Converters can be removed / added by adjusting the following configuration:

``` php
[
'converters' => [
\ParamConverter\EntityParamConverter::class,
\ParamConverter\DateTimeParamConverter::class,
\ParamConverter\BooleanParamConverter::class,
\ParamConverter\IntegerParamConverter::class,
\ParamConverter\FloatParamConverter::class
]
]
];
```

### Creating a converter

All converters must implement the `ParamConverterInterface`.

## Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

## Credits

- [Iacovos Constantinou][link-author]
- [All Contributors][link-contributors]

## License

The MIT License (MIT). Please see [License File](LICENSE) for more information.

[link-author]: https://github.com/softius
[link-contributors]: ../../contributors