PHPackages                             assegaiphp/forms - 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. assegaiphp/forms

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

assegaiphp/forms
================

A simple PHP library for dealing with HTML form submissions.

0.9.0(1mo ago)0239↓62.5%1MITPHPPHP &gt;=8.4CI passing

Since Sep 1Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/assegaiphp/forms)[ Packagist](https://packagist.org/packages/assegaiphp/forms)[ RSS](/packages/assegaiphp-forms/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (7)Dependencies (8)Versions (11)Used By (1)

 [![Assegai Logo](https://camo.githubusercontent.com/d7dab2658d76e460e31be249de2fe5d420f7a7237eb9f2a315f83123632a3b6c/68747470733a2f2f617373656761697068702e636f6d2f696d616765732f6c6f676f732f6c6f676f2d63726f707065642e706e67)](https://assegaiphp.com/)

 [![Latest release](https://camo.githubusercontent.com/f3d35233dbee75ac7b3b6aa00a7252ff6af000d438a57e870a50d5bd6e03364d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f617373656761697068702f666f726d733f646973706c61795f6e616d653d74616726736f72743d73656d766572267374796c653d666c61742d737175617265)](https://github.com/assegaiphp/forms/releases) [![Tests](https://camo.githubusercontent.com/132dc3b9880db13ed13b4063dc1075e73fd429cb3b4eb0abecfc2b39845886da/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f617373656761697068702f666f726d732f7068702e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/assegaiphp/forms/actions/workflows/php.yml) [![PHP 8.4+](https://camo.githubusercontent.com/51482859d8bb7cd31d259f58cf02b8eb7e56c51ad36c462afa3484f3b7a8fc2c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342532422d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/51482859d8bb7cd31d259f58cf02b8eb7e56c51ad36c462afa3484f3b7a8fc2c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342532422d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870266c6f676f436f6c6f723d7768697465) [![License](https://camo.githubusercontent.com/c10243c75922f913392fb8f951dace36323b9e159c7d9ea3cdced7abba8543b9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f617373656761697068702f666f726d733f7374796c653d666c61742d737175617265)](https://github.com/assegaiphp/forms/blob/main/LICENSE) [![Status active](https://camo.githubusercontent.com/1214b36790042a591c22d285a8cbfdc3c33d1cbbbed099a0bca2f5edd79ca2a0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d6163746976652d3130623938313f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/1214b36790042a591c22d285a8cbfdc3c33d1cbbbed099a0bca2f5edd79ca2a0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d6163746976652d3130623938313f7374796c653d666c61742d737175617265)

A progressive [PHP](https://php.net) framework for building effecient and scalable server-side applications.

Description
-----------

[](#description)

Assegai is a framework for building efficient, scalable [PHP](https://php.net) server-side applications. It uses modern PHP (PHP 8.4+) and combines elements of OOP (Object Oriented Programming) and FP (Functional Programming).

Overview
--------

[](#overview)

The AssegaiPHP Forms Library is a powerful and flexible tool for managing HTML forms submitted using POST, PUT, or PATCH requests. This library is designed to simplify the process of handling form data, validation, and submission in PHP web applications. It provides a clean and intuitive interface for creating, processing, and validating forms, making it easier for developers to build robust and secure web applications.

Contribution workflow
---------------------

[](#contribution-workflow)

For commit and pull request conventions in this repo, see:

- [docs/commit-and-pr-guidelines.md](./docs/commit-and-pr-guidelines.md)

Git hooks for this repository live in [`.githooks`](./.githooks). Running `composer install` or `composer update`will automatically configure `core.hooksPath` for this clone so the committed `pre-push` checks are used. If you need to apply the hook configuration manually, run:

```
composer run hooks:install
```

Features
--------

[](#features)

- **Form Creation:** Easily create HTML forms programmatically using a simple and intuitive syntax.
- **Form Fields:** Support for various types of form fields such as text fields, numeric fields, and more.
- **Data Binding:** Automatically populate form fields with data from your models or arrays.
- **Validation:** Define validation rules for form fields and perform server-side validation effortlessly.
- **Error Handling:** Automatically retrieve validation errors for form fields.
- **Customization:** Highly customizable rendering and extending capabilities.
- **Compatibility:** Works well with modern PHP applications and follows best practices.

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

[](#installation)

You can install the AssegaiPHP Forms Library using [Composer](https://getcomposer.org/):

```
composer require assegaiphp/forms
```

Quick Start
-----------

[](#quick-start)

1. **Create a Form:**```
    use Assegai\Forms\Form;
    use Assegai\Forms\Enumerations\HttpMethod;

    $form = new Form(
        method: HttpMethod::POST,
        selector: '#contact-form'
    );
    ```
2. **Add Form Fields:**```
    $form->set('name', '');
    $form->set('email', '');
    $form->set('message', '');
    ```
3. **Process Form Submission:**```
    if ($form->isSubmitted()) {
        // Validate the form
        $form->validate();
        if ($form->isValid()) {
            // Process the form data
            $data = $form->getData();
            // ...
        } else {
            $errors = $form->getErrors();
            // Handle validation errors
        }
    }
    ```
4. **Render the Form:**```
    echo $form->render();
    ```

Advanced Usage
--------------

[](#advanced-usage)

### Adding Validation Rules

[](#adding-validation-rules)

```
use Assegai\Forms\Form;
use Assegai\Forms\Enumerations\HttpMethod;
use Assegai\Forms\FormControls\TextField;

$form = new Form(method: HttpMethod::POST, selector: '#user-form');

// Create a field with validation rules
$nameField = new TextField('name', '', ['required', 'min:3']);
$form->addField($nameField);

// Or add fields and set validation rules later
$form->set('email', '');
$emailField = $form->getField('email');
$emailField->addValidationRules('required', 'email');
```

### Getting Form Data

[](#getting-form-data)

```
// Get data as an associative array
$data = $form->getData();

// Get data as a stdClass object
$dataObject = $form->getData(asObject: true);
```

### Working with Individual Fields

[](#working-with-individual-fields)

```
// Check if a field exists
if ($form->has('name')) {
    // Get a specific field value
    $name = $form->getFieldValue('name');

    // Get the field object
    $nameField = $form->getField('name');

    // Remove a field
    $form->removeField('name');
}
```

### Form HTTP Methods

[](#form-http-methods)

The form supports multiple HTTP methods:

```
use Assegai\Forms\Enumerations\HttpMethod;

// POST forms
$postForm = new Form(method: HttpMethod::POST, selector: '#form');

// GET forms
$getForm = new Form(method: HttpMethod::GET, selector: '#search');

// PUT/PATCH forms for updates
$updateForm = new Form(method: HttpMethod::PUT, selector: '#update-form');
$patchForm = new Form(method: HttpMethod::PATCH, selector: '#patch-form');
```

### Form Selector

[](#form-selector)

The selector parameter can be used to set the form's ID, CSS class, or action URL:

```
// Set the form ID
$form = new Form(selector: '#my-form');

// Set the form CSS classes
$form = new Form(selector: '.form-class1.form-class2');

// Set the form action URL
$form = new Form(selector: '/submit-form');
```

For more detailed usage and customization options, please refer to the [Documentation](docs/README.md).

Contributing
------------

[](#contributing)

We welcome contributions from the community! If you'd like to contribute to the AssegaiPHP Forms Library, please follow our [Contribution Guidelines](CONTRIBUTING.md).

License
-------

[](#license)

The AssegaiPHP Forms Library is open-source software licensed under the [MIT License](LICENSE).
-----------------------------------------------------------------------------------------------

[](#the-assegaiphp-forms-library-is-open-source-software-licensed-under-the-mit-license)

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance88

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

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 ~161 days

Recently: every ~234 days

Total

7

Last Release

59d ago

PHP version history (2 changes)0.4.0PHP &gt;=8.2

0.4.5PHP &gt;=8.4

### Community

Maintainers

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

---

Top Contributors

[![amasiye](https://avatars.githubusercontent.com/u/5607605?v=4)](https://github.com/amasiye "amasiye (57 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/assegaiphp-forms/health.svg)

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

###  Alternatives

[jakeasmith/http_build_url

Provides functionality for http\_build\_url() to environments without pecl\_http.

19818.5M106](/packages/jakeasmith-http-build-url)[webarchitect609/bitrix-neverinclude

Automatic Bitrix modules loader helps you to forget about CModule::IncludeModule and Loader::includeModule.

1015.1k](/packages/webarchitect609-bitrix-neverinclude)

PHPackages © 2026

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