PHPackages                             alexboo/phalcon-annotation-mapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. alexboo/phalcon-annotation-mapper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

alexboo/phalcon-annotation-mapper
=================================

Mapping data by annotation

0.4.x-dev(9y ago)15093GPLv2PHPPHP &gt;=5.4.0

Since Jan 15Pushed 8y ago1 watchersCompare

[ Source](https://github.com/alexboo/phalcon-annotation-mapper)[ Packagist](https://packagist.org/packages/alexboo/phalcon-annotation-mapper)[ Docs](https://github.com/alexboo/phalcon-annotation-mapper)[ RSS](/packages/alexboo-phalcon-annotation-mapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

Phalcon annotation mapper
=========================

[](#phalcon-annotation-mapper)

Mapping data from object or associative array to object implements \\Alexboo\\AnnotationMapper\\MapperInterface

### Install

[](#install)

You can install it using the composer. But it need phalcon framework php extension.

```
composer require alexboo/phalcon-annotation-mapper

```

### Examples

[](#examples)

```
class Example extends \Alexboo\AnnotationMapper\Mapper
{
    /**
     * @Mapped(property="priceOut", type="float", precision=2)
     */
    public $price;

    /**
     * @Mapped(type="integer")
     */
    protected $count;

    /**
     * @Mapped(type="float[]")
     */
    public $array;

    /**
     * @Mapped(type="Example2[]")
     */
    public $object;

    public function setCount($value) {
        $this->count = $value;
    }
}

class Example2 extends \Alexboo\AnnotationMapper\Mapper
{
    /**
     * @Mapped(type="integer")
     */
    public $propertyOne;

    /**
     * @Mapped(type="float")
     */
    public $propertyTwo;

    /**
     * @Mapped(type="string")
     */
    public $propertyThree;
}

$donator = [
    'priceOut' => '1000.51000',
    'count' => 100,
    'array' => ['1.222','2.333','3.400000'],
    'object' => [[
        'propertyOne' => '1000.500',
        'propertyTwo' => '2000.500',
        'propertyThree' => ' aaaddd '
    ]]
];

$example = new Example();

$example->mapping($donator);

var_dump($example);

$donator = new stdClass();
$donator->priceOut = '2000.52000';
$donator->count = 200;
$donator->array = [4,5,6];
$donator->object = [[
    'propertyOne' => '1000.520',
    'propertyTwo' => '2000.520',
    'propertyThree' => ' aaaddd '
]];

$example = new Example();

$example->mapping($donator);

var_dump($example);

```

### Additional options.

[](#additional-options)

Caster float and string support additional options. For float caster you can set precision (number of digits after the decimal point). For string you can disabled or enabled (using by default) trim all string.

```
 // Set default precision for all properties with float type

 \Alexboo\AnnotationMapper\Cast\Float::setDefaultPrecision(1);

 class Example3 extends \Alexboo\AnnotationMapper\Mapper
 {
     /**
      * @var float $field1
      * @Mapped(type="float")
      */
     public $field1;
     /**
      * @var float $field2
      * @Mapped(type="float")
      */
     public $field2;
 }

 $example = new Example3();
 $example->mapping([
     'field1' => '15.123456',
     'field2' => '987.654123',
 ]);

 var_dump($example);

 // Disabled/enabled trim string data

 class Example4 extends \Alexboo\AnnotationMapper\Mapper
 {
     /**
      * @Mapped(type="string")
      */
     public $field1;
     /**
      * @Mapped(type="string")
      */
     public $field2;
 }

 \Alexboo\AnnotationMapper\Cast\String::isTrim(false);

 $example = new Example4();
 $example->mapping([
     'field1' => '   asdasd  asdasdasd   ',
     'field2' => '        ',
 ]);

 var_dump($example);

 \Alexboo\AnnotationMapper\Cast\String::isTrim(true);

 $example = new Example4();
 $example->mapping([
     'field1' => '   asdasd  asdasdasd   ',
     'field2' => '        ',
 ]);

 var_dump($example);

```

### Create you custer

[](#create-you-custer)

You can create custom custer if you need. Than you can specify it like type of property. Caster must implements \\Alexboo\\AnnotationMapper\\CastCastInterface

```
/**
 * Cast all data to "blabla" string
 * Class BlaBlaCaster
 */
class BlaBlaCaster extends \Alexboo\AnnotationMapper\Cast\CastAbstract
{
    public function cast($value) {
        return "blabla";
    }
}

class Example5 extends \Alexboo\AnnotationMapper\Mapper
{
    /**
     * @Mapped(type="BlaBlaCaster")
     */
    public $field1;
    /**
     * @Mapped(type="\Alexboo\AnnotationMapper\Cast\Integer")
     */
    public $field2;
}

$example = new Example5();
$example->mapping([
    'field1' => 'Say something very clever!',
    'field2' => 123213213,
]);

var_dump($example);

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~67 days

Total

4

Last Release

3565d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/abb2ecc0fba61c8266d041a2e33214e403d386df1ae003045074297d906621d2?d=identicon)[alexboo](/maintainers/alexboo)

---

Top Contributors

[![alexboo](https://avatars.githubusercontent.com/u/2115000?v=4)](https://github.com/alexboo "alexboo (16 commits)")

---

Tags

mapperphalconannotation

### Embed Badge

![Health badge](/badges/alexboo-phalcon-annotation-mapper/health.svg)

```
[![Health](https://phpackages.com/badges/alexboo-phalcon-annotation-mapper/health.svg)](https://phpackages.com/packages/alexboo-phalcon-annotation-mapper)
```

###  Alternatives

[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[phalcon/zephir

Zephir is a compiled high level language aimed to the creation of C-extensions for PHP

3.4k414.1k18](/packages/phalcon-zephir)[eventsauce/object-hydrator

Converts structured data into strict objects.

3322.3M20](/packages/eventsauce-object-hydrator)[phalcon/ide-stubs

The most complete Phalcon Framework IDE stubs library which enables autocompletion in modern IDEs.

1623.1M121](/packages/phalcon-ide-stubs)[koriym/attributes

An annotation/attribute reader

433.4M12](/packages/koriym-attributes)[hyperf/di

A DI for Hyperf.

182.8M594](/packages/hyperf-di)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
