PHPackages                             simfatic/formhandler - 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. simfatic/formhandler

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

simfatic/formhandler
====================

A basic generic form processor in PHP

1.1.3(4y ago)2111[1 issues](https://github.com/simfatic/FormHandler/issues)MITPHPCI failing

Since Apr 29Pushed 4y ago2 watchersCompare

[ Source](https://github.com/simfatic/FormHandler)[ Packagist](https://packagist.org/packages/simfatic/formhandler)[ RSS](/packages/simfatic-formhandler/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (3)Versions (8)Used By (0)

A simple PHP form handler
=========================

[](#a-simple-php-form-handler)

This package can be used to create simple PHP scripts that handles a form submission. At the moment, this PHP form handler validates, handles captcha, emails form submissions, and handles file attachments

### Simple usage

[](#simple-usage)

```
use Simfatic\FormHandler\FormHandler;

$fh = new FormHandler();

$fh->validate(function($validator)
{
	$validator->field('name')->isRequired();
	$validator->field('email')->isEmail()->isRequired();

})->sendEmailTo('someone@website.com');

echo $fh->process($_POST);
```

Form validations are done using [Simfatic\\Boar](https://github.com/simfatic/boar). So any of the customizations can go in the validate callback.

Customizing the mailer
----------------------

[](#customizing-the-mailer)

The FormHandler uses PHPMailer. The options can be customized like this:

```
use Simfatic\FormHandler\FormHandler;

$fh = new FormHandler();

$fh->validate(function($validator)
{
	$validator->field('name')->isRequired();
	$validator->field('email')->isEmail()->isRequired();

})->configMailer(function($mailer)
{
	$mailer->setFrom('someone@yourwebsite.com','Form',false);

	$mailer->isSMTP();                                    // Send using SMTP
    $mailer->Host       = 'smtp.example.com';             // Set the SMTP server to send through
    $mailer->SMTPAuth   = true;                           // Enable SMTP authentication
    $mailer->Username   = 'user@example.com';             // SMTP username
    $mailer->Password   = 'secret';                       // SMTP password
    $mailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
	$mailer->Port       = 587;

	/*
	Example: adding Cc
	$mail->addCC('cc@example.com');
	*/

})->sendEmailTo('someone@gmail.com');

echo $fh->process($_POST);
```

File attachments
----------------

[](#file-attachments)

call attachFiles passing the name of the file upload fields.

```
$fh = new FormHandler();

$fh->validate(function($validator)
{
    $validator->field('name')->isRequired();
    $validator->field('email')->isEmail()->isRequired();

})->attachFiles(['image'])
->sendEmailTo('someone@gmail.com');
```

ReCaptcha v2
------------

[](#recaptcha-v2)

In order to show the "I am not a robot" checkbox, create a div in your form like so:

```

```

Then update the handler:

```
use Simfatic\FormHandler\FormHandler;

$pp = new FormHandler();

$pp->validate(function($validator)
{
	$validator->field('name')->isRequired();
	$validator->field('email')->isEmail()->isRequired();
})
->requireReCaptcha(function($recaptcha)
{
	$recaptcha->initSecretKey('xxxxxx');
})
->configMailer(function($mailer)
{
	$mailer->setFrom('someone@form.guide','Form',false);
})
->sendEmailTo('someone@gmail.com');

echo $pp->process($_POST);
```

See a complete example in the [examples folder](examples/4-recaptcha/README.md)

Client side handling
--------------------

[](#client-side-handling)

You can directly provide the link to your custom handler.php in the action attribute of the form.

Another alternative is to use Javascript to process the response from the form. The response from the process() function is JSON. Here is an example. This example uses jQuery.

```
$(function()
{
	$('#contact_form').submit(function(e)
	{
		e.preventDefault();
		$.post( 'handler.php', $('form#contact_form').serialize(),
		    function(data)
		      {
                if(data.result == 'success')
                {
                    $('form#contact_form').hide();
                    $('#success_message').show();
                }
                else
                {
                    $('#error_message').append('')
                    jQuery.each(data.errors,function(key,val)
                    {
                        $('#error_message ul').append(''+key+':'+val+'');
                    });
                    $('#error_message').show();

                }

		      },'json');
	});
});
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

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

Recently: every ~409 days

Total

7

Last Release

1691d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/968329?v=4)[Prasanth Janardhanan](/maintainers/prasanthmj)[@prasanthmj](https://github.com/prasanthmj)

---

Top Contributors

[![prasanthmj](https://avatars.githubusercontent.com/u/968329?v=4)](https://github.com/prasanthmj "prasanthmj (16 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/simfatic-formhandler/health.svg)

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)

PHPackages © 2026

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