PHPackages                             imran/form - 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. imran/form

ActiveLibrary[Templating &amp; Views](/categories/templating)

imran/form
==========

A simple and consistent way to generate various types of HTML form fields.

1.0.0(3y ago)08MITPHPPHP &gt;=8.0

Since Jan 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/grim-reapper/form)[ Packagist](https://packagist.org/packages/imran/form)[ RSS](/packages/imran-form/feed)WikiDiscussions main Synced today

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

Form Class
==========

[](#form-class)

The Form class is a utility class that provides a simple and consistent way to generate various types of HTML form fields.

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

[](#installation)

You can [Download](https://github.com/grim-reapper/form/archive/refs/heads/main.zip) the class file and include it in your project.

or you can install by using composer, this is recommended way.

```
composer require imran/form
```

Usage
-----

[](#usage)

### Opening and closing a form

[](#opening-and-closing-a-form)

To create an opening form tag with attributes, use the **`open()`** method:

```
echo Form::open(['action' => '/submit', 'method' => 'post']);
```

To create a closing form tag, use the `close()` method:

```
echo Form::close();
```

### Input fields

[](#input-fields)

To create an input field of any type, use the `input()` method:

```
echo Form::input('text', 'first_name', 'John');
echo Form::input('date', 'birthday', '1990-01-01');
```

To create a textarea field, use the `textarea()` method:

```
echo Form::textarea('message', 'Hello, World!');
```

To create a checkbox field, use the `checkbox()` method:

```
echo Form::checkbox('agreement', 1, true);
```

To create a radio button, use the `radio()` method:

```
echo Form::radio('payment', 'credit', true);
```

To create a file input field, use the `file()` method:

```
echo Form::file('resume');
```

To create a password input field, use the `password()` method:

```
echo Form::password('password');
```

To create an email input field, use the `email()` method:

```
echo Form::email('email', 'example@example.com');
```

To create a label element, use the `label()` method:

```
echo Form::label('email', 'Email');
```

### Registering Custom Types

[](#registering-custom-types)

You can register custom types by using the registerCustomType() method and passing in a name for the custom type and a callback function that will generate the HTML for that custom type.

```
Form::registerCustomType('custom_input', function($type, $name, $value, $attributes = []) {
    $attr_string = Form::attributesToString($attributes);
    return "";
});
```

You can then use the registered custom type by using the `custom()` method and passing in the name of the custom type and an array of parameters to be passed to the callback function

```
echo Form::custom('custom_input', ['text', 'first_name', 'John']);
```

### Running Tests

[](#running-tests)

To run tests, use following command

```
.\vendor\bin\phpunit tests/FormTest.php
```

### Conclusion

[](#conclusion)

The Form class provides a simple and consistent way to generate various types of HTML form fields, making it easy to create forms in your PHP projects. You can also register your custom types to the class, giving you more flexibility and control over your forms. With the `open()` and `close()` methods, you can easily create the basic structure of a form, and with the various other methods, you can add different types of input fields, labels, and buttons to your form. The class also allows you to pass in attributes for each field, giving you more control over the appearance and behavior of your form fields. Overall, the Form class is a useful tool for creating and managing forms in your PHP projects.

### Hi, I'm Imran Ali! 👋

[](#hi-im-imran-ali-)

### 🚀 About Me

[](#-about-me)

Senior **Full-Stack** Developer specializing in front end and back-end development. Experienced with all stages of the development cycle for dynamic web projects. Innovative, creative and a proven team player, I possess a Tech Degree in Front End Development and have 7 years building developing and managing websites, applications and programs for various companies. I seek to secure the position of Senior Full Stack Developer where i can share my skills, expertise and experience with valuable clients.

### 🛠 Skills

[](#-skills)

PHP OOP, Laravel, Codeigniter Javascript, Node, React, Vue, Git, HTML, Rest Api, Typescript, Angular, SCSS, Docker, CI/CD Jenkins, Bootstrap, Responsive Design, ASP.NET Core

### 🔗 Follow on

[](#-follow-on)

[![linkedin](https://camo.githubusercontent.com/9745a59ad4a919d2e524512c3f732c820d4aa0fe927def4f37c4aba08f7e42bc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c696e6b6564696e2d3041363643323f7374796c653d666f722d7468652d6261646765266c6f676f3d6c696e6b6564696e266c6f676f436f6c6f723d7768697465)](https://www.linkedin.com/in/imranali291/)[![twitter](https://camo.githubusercontent.com/79cbea7e1aa9ec614d34050bdc4128542d8527807ac8ce879f953ced3478375d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f747769747465722d3144413146323f7374796c653d666f722d7468652d6261646765266c6f676f3d74776974746572266c6f676f436f6c6f723d7768697465)](https://twitter.com/imranali125)

### License

[](#license)

[![MIT License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://choosealicense.com/licenses/mit/)[![GPLv3 License](https://camo.githubusercontent.com/da9c3abfd62c32a94031c3a382cb7c85dbd4cede411416837adfe6b8fda05ba1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c25323076332d79656c6c6f772e737667)](https://opensource.org/licenses/)[![AGPL License](https://camo.githubusercontent.com/aed477ac82de60abd644cfa7c9d381eebe9a00d5d32168644f7e6d2a23957d1b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4147504c2d626c75652e737667)](http://www.gnu.org/licenses/agpl-3.0)

### Contributing

[](#contributing)

Contributions are always welcome!

See `contributing.md` for ways to get started.

Please adhere to this project's `code of conduct`.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Total

2

Last Release

1257d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7252105628ffa6f064585370161626c7c72e68dd2e74ee66aa50d5894543c183?d=identicon)[webz2feel](/maintainers/webz2feel)

---

Top Contributors

[![grim-reapper](https://avatars.githubusercontent.com/u/7957389?v=4)](https://github.com/grim-reapper "grim-reapper (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/imran-form/health.svg)

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

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3851.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.1k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.3k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

282.2k](/packages/webkinder-sproutset)

PHPackages © 2026

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