PHPackages                             kunicmarko/form-annotation-bundle - 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. [Templating &amp; Views](/categories/templating)
4. /
5. kunicmarko/form-annotation-bundle

AbandonedArchivedSymfony-bundle[Templating &amp; Views](/categories/templating)

kunicmarko/form-annotation-bundle
=================================

This is a Symfony Bundle that adds helper annotations for symfony forms.

v1.0.0(8y ago)02.2kMITPHPPHP ^7.1

Since Jan 22Pushed 7y ago1 watchersCompare

[ Source](https://github.com/kunicmarko20/FormAnnotationBundle)[ Packagist](https://packagist.org/packages/kunicmarko/form-annotation-bundle)[ Docs](https://github.com/kunicmarko20/FormAnnotationBundle)[ RSS](/packages/kunicmarko-form-annotation-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (9)Versions (2)Used By (0)

Form Annotation Bundle
======================

[](#form-annotation-bundle)

[![Build Status](https://camo.githubusercontent.com/4bd22fdd247bfab4a88f51888e85ab536f516cb5b5d4fca2af5622812e49952f/68747470733a2f2f7472617669732d63692e6f72672f6b756e69636d61726b6f32302f466f726d416e6e6f746174696f6e42756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kunicmarko20/FormAnnotationBundle)[![Coverage Status](https://camo.githubusercontent.com/85a2f491f0f316bcb33bbe03e02f4f965f772362fd3eccd7ef1a5fb08c6bf037/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6b756e69636d61726b6f32302f466f726d416e6e6f746174696f6e42756e646c652f62616467652e737667)](https://coveralls.io/github/kunicmarko20/FormAnnotationBundle)

Adds Form Annotations that helps you avoid boilerplate code when using forms.

Documentation
-------------

[](#documentation)

- [Installation](#installation)
- [How to use](#how-to-use)
- [Annotations](#annotations)

Installation
------------

[](#installation)

**1.** Add dependency with composer

```
composer require kunicmarko/form-annotation-bundle

```

**2.** Register the bundle in your Kernel

```
$bundles = array(
    // ...
    new KunicMarko\FormAnnotationBundle\FormAnnotationBundle(),
);

```

How to use
----------

[](#how-to-use)

First select the [annotation](#annotations) you want to use and add it to your controller action, you have to provide form class and parameter name, also parameter has to have a type.

While [FOSRestBundle](https://github.com/FriendsOfSymfony/FOSRestBundle) is not dependency, my examples are with FOSRestBundle and this is mainly used with it.

Before:

```
public function createAction(Request $request, UserService $userService)
{
    $form = $this->createForm(CreateUserType::class, $user = new User());

    $form->submit($request->request->all());

    if ($form->isValid()) {
        $userService->createUser($user);

        return View::create($user, Response::HTTP_CREATED);
    }

    return View::create($form);
}

```

After:

```
use KunicMarko\FormAnnotationBundle\Annotation\Form;
use FOS\RestBundle\Controller\Annotations\View;
use Symfony\Component\HttpFoundation\Response;

 /**
 * @Form\Post(
 *     formType=CreateUserType::class,
 *     parameter="user"
 * )
 *
 * @View(statusCode=Response::HTTP_CREATED)
 */
public function createAction(User $user, UserService $userService)
{
    $userService->createUser($user);

    return $user;
}

```

The Request enters controller action only if everything in form is valid, else it will return validation errors.

Annotations
-----------

[](#annotations)

There are 3 options you can set when adding annotation to your action:

- `formType` - FQCN of your form type.
- `parameter` - parameter name you will be using in your action. (parameter has to have a type)
- `clearMissing` - if some value is not sent this will by default set it to null for `POST`/`PUT` but for `PATCH` this value will be ignored. You can control this on your own if you want.

### Post

[](#post)

```
use KunicMarko\FormAnnotationBundle\Annotation\Form;
use FOS\RestBundle\Controller\Annotations\View;
use Symfony\Component\HttpFoundation\Response;

 /**
 * @Form\Post(
 *     formType=CreateUserType::class,
 *     parameter="user"
 * )
 *
 * @View(statusCode=Response::HTTP_CREATED)
 */
public function createAction(
    User $user,
    UserService $userService
) {
    $userService->createUser($user);

    return $user;
}

```

In `POST` we take your parameter and from type you provided. We create new Object and populate data from Request and if everything is valid we populate the parameter in your action and we let Request enter your action else we return form errors.

### Patch/Put

[](#patchput)

```
use KunicMarko\FormAnnotationBundle\Annotation\Form;
use FOS\RestBundle\Controller\Annotations\View;
use Symfony\Component\HttpFoundation\Response;

 /**
 * @Form\Put(
 *     formType=UpdateUserType::class,
 *     parameter="user"
 * )
 *
 * @View(statusCode=Response::HTTP_OK)
 */
public function updateAction(
    User $user,
    UserService $userService
) {
    $userService->updateUser($user);

    return $user;
}

```

Here we depend on Symfony ParamConverter and we expect that the parameter you provided is already a populated object. If you add `{id}` parameter to your route and type-hint it with Doctrine Entity, Symfony ParamConverter will already do that. If everything is valid we let Request enter your action else we return form errors.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3031d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c1e666a733b6e07ad9507caffe4fb9ddbf91f9f2676bafd4845bc56cfdbe892?d=identicon)[kunicmarko20](/maintainers/kunicmarko20)

---

Top Contributors

[![kunicmarko20](https://avatars.githubusercontent.com/u/13528674?v=4)](https://github.com/kunicmarko20 "kunicmarko20 (6 commits)")

---

Tags

annotationssymfonysymfony-bundlesymfony-formssymfonyannotationsFormssymfony forms

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kunicmarko-form-annotation-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/kunicmarko-form-annotation-bundle/health.svg)](https://phpackages.com/packages/kunicmarko-form-annotation-bundle)
```

###  Alternatives

[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[a2lix/auto-form-bundle

Automate form building

873.8M11](/packages/a2lix-auto-form-bundle)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)

PHPackages © 2026

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