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

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

myschoolmanagement/bindto
=========================

Simple way to bind Request to DTO/Commands

3.0.1(3w ago)01281MITPHPPHP &gt;=8.1

Since Apr 20Pushed 3w ago8 watchersCompare

[ Source](https://github.com/MySchoolManagement/bindto)[ Packagist](https://packagist.org/packages/myschoolmanagement/bindto)[ RSS](/packages/myschoolmanagement-bindto/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (27)Versions (40)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

55

—

FairBetter than 97% of packages

Maintenance94

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 58.5% 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 ~123 days

Recently: every ~105 days

Total

31

Last Release

26d ago

Major Versions

0.4.11 → 1.0.02019-04-23

1.0.1 → 2.0.02019-06-27

2.0.10 → 3.0.02026-05-29

PHP version history (3 changes)v0.1.0PHP &gt;=5.5

1.0.0PHP &gt;=7.2

2.0.10PHP &gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![iainmckay](https://avatars.githubusercontent.com/u/1223726?v=4)](https://github.com/iainmckay "iainmckay (38 commits)")[![liuggio](https://avatars.githubusercontent.com/u/530406?v=4)](https://github.com/liuggio "liuggio (12 commits)")[![rfoliveira01](https://avatars.githubusercontent.com/u/1055857?v=4)](https://github.com/rfoliveira01 "rfoliveira01 (4 commits)")[![garak](https://avatars.githubusercontent.com/u/179866?v=4)](https://github.com/garak "garak (3 commits)")[![seb2411](https://avatars.githubusercontent.com/u/1470048?v=4)](https://github.com/seb2411 "seb2411 (2 commits)")[![capriolo](https://avatars.githubusercontent.com/u/6237479?v=4)](https://github.com/capriolo "capriolo (2 commits)")[![giorrrgio](https://avatars.githubusercontent.com/u/482501?v=4)](https://github.com/giorrrgio "giorrrgio (1 commits)")[![cirpo](https://avatars.githubusercontent.com/u/51252?v=4)](https://github.com/cirpo "cirpo (1 commits)")[![rrhvella](https://avatars.githubusercontent.com/u/678295?v=4)](https://github.com/rrhvella "rrhvella (1 commits)")[![agiuliano](https://avatars.githubusercontent.com/u/1260243?v=4)](https://github.com/agiuliano "agiuliano (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

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

8.5k5.8M717](/packages/sylius-sylius)[akeneo/pim-community-dev

Akeneo PIM, the future of catalog management is open!

1.0k624.1k86](/packages/akeneo-pim-community-dev)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M528](/packages/shopware-core)[cognesy/instructor-php

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

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

EC-CUBE EC open platform.

78727.2k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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