PHPackages                             oswa/formify-php - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. oswa/formify-php

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

oswa/formify-php
================

A flexible and easy-to-use PHP form builder library

0.0.1(6mo ago)09MITPHPPHP 8.3.\*

Since Dec 21Pushed 5mo agoCompare

[ Source](https://github.com/oswaldohuillca/formify-php)[ Packagist](https://packagist.org/packages/oswa/formify-php)[ Docs](https://github.com/oswaldohuillca/formify-php)[ RSS](/packages/oswa-formify-php/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (2)Used By (0)

FormifyPhp
==========

[](#formifyphp)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bb95c46e6b308704d8116ee226adbc87b286c8d9525de46df5ec8cd0b4a85740/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f7377612f666f726d6966792d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oswa/formify-php)[![Total Downloads](https://camo.githubusercontent.com/1b2cecbf1afa110488b382a28c19c3d1d6ad35721973176cebea953442cd309d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f7377612f666f726d6966792d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oswa/formify-php)

Una librería flexible y fácil de usar para construir formularios HTML en PHP.

Instalación
-----------

[](#instalación)

Puedes instalar el paquete via Composer:

```
composer require oswa/formify-php
```

Uso
---

[](#uso)

### Uso Básico

[](#uso-básico)

```
use Oswa\FormifyPhp\FormifyPhp;

// Crear un nuevo formulario
$form = new FormifyPhp('POST', '/submit');

// Agregar campos
$form->addField('text', 'name', [
    'label' => 'Nombre',
    'required' => true,
    'placeholder' => 'Tu nombre',
    'class' => 'form-control'
]);

$form->addField('email', 'email', [
    'label' => 'Email',
    'required' => true
]);

$form->addField('textarea', 'message', [
    'label' => 'Mensaje',
    'rows' => 5
]);

// Agregar botón de submit
$form->submitButton([
    'text' => 'Enviar',
    'class' => 'btn btn-primary'
]);

// O simplemente con string
$form->submitButton('Enviar');

// Renderizar el formulario
echo $form->render();
```

### Personalización Global de Labels

[](#personalización-global-de-labels)

Puedes customizar cómo se renderizan todos los labels del formulario:

```
$form = new FormifyPhp('POST', '/submit');

// Personalizar el renderizado de labels para todos los campos
$form->setRenderLabel(function ($field) {
    return sprintf(
        '%s%s',
        $field['name'],
        $field['label'],
        $field['required'] ? ' *' : ''
    );
});

$form->addField('text', 'name', ['label' => 'Nombre', 'required' => true]);
```

### Personalización por Campo Individual

[](#personalización-por-campo-individual)

Cada campo puede tener su propio renderizado completamente personalizado usando `customRenderer` dentro de las opciones:

```
$form = new FormifyPhp('POST', '/submit');

// Campo con diseño personalizado (input dentro del label)
$form->addField('email', 'email', [
    'label' => 'Correo Electrónico',
    'placeholder' => 'tu@email.com',
    'required' => true,
    'customRenderer' => function ($field) {
        return sprintf(
            '' .
            '' .
            '%s' .
            '' .
            '' .
            '',
            htmlspecialchars($field['options']['label']),
            $field['type'],
            $field['name']
        );
    }
]);
```

### Wrapper Personalizado para Campos

[](#wrapper-personalizado-para-campos)

Define cómo se envuelve cada campo globalmente:

```
$form->setFieldWrapper(function ($field) {
    $html = '' . PHP_EOL;
    $html .= $field['label'];
    $html .= $field['input'];

    if ($field['error']) {
        $html .= sprintf('%s', $field['error']);
    }

    $html .= '' . PHP_EOL;
    return $html;
});
```

### Ejemplo con Tailwind CSS

[](#ejemplo-con-tailwind-css)

```
$form = new FormifyPhp('POST', '/submit');

$form->setAttributes(['class' => 'space-y-6']);

$form->setRenderLabel(function ($field) {
    return sprintf(
        '%s%s',
        $field['name'],
        $field['label'],
        $field['required'] ? ' *' : ''
    );
});

$form->addField('text', 'name', [
    'label' => 'Nombre completo',
    'required' => true,
    'class' => 'mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500'
]);

// Campo con custom renderer
$form->addField('email', 'email', [
    'label' => 'Email',
    'required' => true,
    'class' => 'mt-1 block w-full rounded-md border-gray-300',
    'customRenderer' => function ($field) {
        return sprintf(
            '' .
            '...' .
            '%s' .
            '' .
            '',
            $field['options']['label'],
            $field['name'],
            $field['options']['class']
        );
    }
]);

// Submit button con custom renderer
$form->submitButton([
    'text' => 'Enviar',
    'class' => 'w-full bg-indigo-600 text-white rounded-lg px-6 py-3',
    'customRenderer' => function ($field) {
        return sprintf(
            '' .
            '%s' .
            '',
            $field['options']['class'] ?? '',
            $field['text']
        );
    }
]);

echo $form->render();
```

### Manejo de Errores

[](#manejo-de-errores)

```
$form = new FormifyPhp('POST', '/submit');
$form->addField('email', 'email', ['label' => 'Email']);

// Establecer errores de validación
$form->setErrors([
    'email' => 'El email no es válido'
]);

echo $form->render();
```

Características
---------------

[](#características)

- ✅ Constructor de formularios fluido y encadenable
- ✅ Soporte para todos los tipos de campos HTML5
- ✅ **Renderizado personalizable a nivel global y por campo**
- ✅ **Labels personalizables** - puedes poner el input dentro del label o cualquier diseño
- ✅ **Wrapper personalizable** para controlar cómo se envuelve cada campo
- ✅ **customRenderer en options** - API limpia y consistente
- ✅ **Compatible con Tailwind CSS, Bootstrap y cualquier framework CSS**
- ✅ Validación de campos y mensajes de error
- ✅ Clases CSS completamente personalizables
- ✅ Botones de submit con atributos y renderers personalizados

Requisitos
----------

[](#requisitos)

- PHP 8.0 o superior

Testing
-------

[](#testing)

Los tests están escritos con [Pest](https://pestphp.com/):

```
composer test
```

O ejecutar Pest directamente:

```
./vendor/bin/pest
```

Changelog
---------

[](#changelog)

Por favor ver [CHANGELOG](CHANGELOG.md) para más información sobre cambios recientes.

Contribuir
----------

[](#contribuir)

Las contribuciones son bienvenidas. Por favor ver [CONTRIBUTING](CONTRIBUTING.md) para más detalles.

Seguridad
---------

[](#seguridad)

Si descubres algún problema de seguridad, por favor envía un email a .

Créditos
--------

[](#créditos)

- [Oswa](https://github.com/oswaldohuillca)

Licencia
--------

[](#licencia)

La licencia MIT (MIT). Por favor ver [License File](LICENSE) para más información.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance70

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

195d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/79205?v=4)[Oswaldo Gutiérrez](/maintainers/oswa)[@oswa](https://github.com/oswa)

---

Top Contributors

[![oswaldohuillca](https://avatars.githubusercontent.com/u/75394499?v=4)](https://github.com/oswaldohuillca "oswaldohuillca (9 commits)")

---

Tags

validationhtmlformform-builder

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/oswa-formify-php/health.svg)

```
[![Health](https://phpackages.com/badges/oswa-formify-php/health.svg)](https://phpackages.com/packages/oswa-formify-php)
```

###  Alternatives

[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.4M50](/packages/proengsoft-laravel-jsvalidation)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2462.4M7](/packages/laravel-validation-rules-credit-card)[intervention/validation

Additional validation rules for the Laravel framework

6827.2M20](/packages/intervention-validation)[illuminate/validation

The Illuminate Validation package.

18838.2M1.7k](/packages/illuminate-validation)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel

3893.6M1](/packages/axlon-laravel-postal-code-validation)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

762649.9k18](/packages/wendelladriel-laravel-validated-dto)

PHPackages © 2026

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