PHPackages                             pugx/bindto - 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. pugx/bindto

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

pugx/bindto
===========

Simple way to bind Request to DTO/Commands

v0.1.1(10y ago)14327[3 PRs](https://github.com/PUGX/Bindto/pulls)MITPHPPHP &gt;=5.5

Since Jul 7Pushed 7y ago7 watchersCompare

[ Source](https://github.com/PUGX/Bindto)[ Packagist](https://packagist.org/packages/pugx/bindto)[ RSS](/packages/pugx-bindto/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (5)Used By (0)

Bindto
======

[](#bindto)

#### Simplest way to bind Request to DTO/Commands.

[](#simplest-way-to-bind-request-to-dtocommands)

Bindto helps you to work with API and data validation using DTO and Commands.

Is really fast (it doesn't use Reflection) and binds the Request against your class.

It's the smartest way to stop using the slow and complex Symfony Form component for API.

Install
-------

[](#install)

`composer require pugx/bindto`

Usage
-----

[](#usage)

Example, you have to create a Post/Patch/Put Api

### 1. Create a simple class that is the body of a request

[](#1-create-a-simple-class-that-is-the-body-of-a-request)

##### protip: you can use with Symfony validation component annotations

[](#protip-you-can-use-with-symfony-validation-component-annotations)

```
use Symfony\Component\Validator\Constraints as Assert;

Class CreateFeedback {

    /**
     * @Assert\NotBlank(groups={"POST"})
     * @Assert\Type(type="string")
     */
    public $subject;

    /**
     * @Assert\NotNull(groups={"POST"})
     * @Assert\Type(type="string")
     * @Assert\Length(
     *      min = 10,
     *      max = 500)
     */
    public $body;
}
```

### 2. In your controller

[](#2-in-your-controller)

if you use Silex you may want to enforce the input validation, improving the example at :

```
require_once __DIR__.'/../vendor/autoload.php';

use Bindto\Binder;

$app = new Silex\Application();

$app->post('/feedback', function (Request $request) {

    $binder = Binder::createSimpleProductionBinder();
    $result = $binder->bind($request, CreateFeedback::class);
    if (!$result->isValid()) {
        throw new \Exception($result->getViolations());
    }
    $createFeedBack = $result->getData();
    mail($createFeedBack->subject, '[YourSite] Feedback', $createFeedBack->body);

    return new Response('Thank you for your feedback!', 201);
});

$app->run();
```

PATCH support with partial modification
---------------------------------------

[](#patch-support-with-partial-modification)

Use the validation groups if you want to PATCH partially:

```
/**
 * @Assert\NotNull(groups={"POST"})
 * @Assert\Type(type="string")
 * @Assert\Length(
 *      min = 10,
 *      max = 500)
 */
public $body;
```

With a POST request all the assertions will be used, with a PUT and PATCH only the `Type` and `Length` assertions.

TODO
----

[](#todo)

- recursive binder?
- collection?
- twig helper?
- tests decouple maptest from bindertest
- silex provider?
- sf bundle?

Run tests
---------

[](#run-tests)

```
composer dump-autoload
bin/phpunit
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% 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 ~0 days

Total

2

Last Release

3679d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/446a646f719434553ab25f0f931d28ec09fbb036528126ac7e9d54a2e8132581?d=identicon)[liuggio](/maintainers/liuggio)

---

Top Contributors

[![liuggio](https://avatars.githubusercontent.com/u/530406?v=4)](https://github.com/liuggio "liuggio (12 commits)")[![garak](https://avatars.githubusercontent.com/u/179866?v=4)](https://github.com/garak "garak (3 commits)")[![iainmckay](https://avatars.githubusercontent.com/u/1223726?v=4)](https://github.com/iainmckay "iainmckay (3 commits)")[![agiuliano](https://avatars.githubusercontent.com/u/1260243?v=4)](https://github.com/agiuliano "agiuliano (1 commits)")[![cirpo](https://avatars.githubusercontent.com/u/51252?v=4)](https://github.com/cirpo "cirpo (1 commits)")[![giorrrgio](https://avatars.githubusercontent.com/u/482501?v=4)](https://github.com/giorrrgio "giorrrgio (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pugx-bindto/health.svg)

```
[![Health](https://phpackages.com/badges/pugx-bindto/health.svg)](https://phpackages.com/packages/pugx-bindto)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[wallabag/wallabag

open source self hostable read-it-later web application

12.6k2.2k](/packages/wallabag-wallabag)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[symfony/ux-cropperjs

Cropper.js integration for Symfony

19280.3k3](/packages/symfony-ux-cropperjs)[sylius/inventory-bundle

Flexible inventory management for Symfony applications.

19176.7k4](/packages/sylius-inventory-bundle)

PHPackages © 2026

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