PHPackages                             safari/safari - 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. safari/safari

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

safari/safari
=============

A form builder for php.

v2.6.1(2y ago)5371MITPHPPHP &gt;=7.0.0

Since Jan 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/phrenotype/safari)[ Packagist](https://packagist.org/packages/safari/safari)[ RSS](/packages/safari-safari/feed)WikiDiscussions main Synced 1mo ago

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

Safari
======

[](#safari)

[![github stars](https://camo.githubusercontent.com/7b7387ee4e8816cb262a25587b3ca0ea11dc492b16c8d0acc5cc3be71eb3e343/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f706872656e6f747970652f7361666172693f7374796c653d736f6369616c)](https://camo.githubusercontent.com/7b7387ee4e8816cb262a25587b3ca0ea11dc492b16c8d0acc5cc3be71eb3e343/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f706872656e6f747970652f7361666172693f7374796c653d736f6369616c)[![license](https://camo.githubusercontent.com/3b1ce2873579a8990b4fa616111813957826540c7ab646104845362b2a4c0b31/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f706872656e6f747970652f736166617269)](https://camo.githubusercontent.com/3b1ce2873579a8990b4fa616111813957826540c7ab646104845362b2a4c0b31/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f706872656e6f747970652f736166617269)[![contributors](https://camo.githubusercontent.com/40511b0d5ce468e464957abda24942018ada6d9f4d5dfed558bf4eea94533c77/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f706872656e6f747970652f736166617269)](https://camo.githubusercontent.com/40511b0d5ce468e464957abda24942018ada6d9f4d5dfed558bf4eea94533c77/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f706872656e6f747970652f736166617269)[![code size](https://camo.githubusercontent.com/1800f0445744d3379932c403e6bf7badb68345f4c2d0fed84eb9649de985a99c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f706872656e6f747970652f736166617269)](https://camo.githubusercontent.com/1800f0445744d3379932c403e6bf7badb68345f4c2d0fed84eb9649de985a99c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f706872656e6f747970652f736166617269)

This library makes php forms easy to build and re-use, yes, re-use.

Just like orm models are simply declared and used over and over again, php form can be declared as classes with form elements defined and simply rendered when the need arises.

Previously submitted form values are automatically filled or choosen.

Install
-------

[](#install)

```
composer require safari/safari

```

Usage
-----

[](#usage)

For each form, you need to define a class that extends `Safari\Form`, an abstract class. Ensure the parent constructor in called within your own constructor. The super global containing the form values should be passed to it. The super global is automatically encoded using `htmlentities` to prevent `xss`.

Additionally, you can optionally assign form attributes in the constructor. However, make sure you declare them as instance attributes or you will be unable to retrieve the values later.

Then, you are required to implement a method, `elements`, which returns an array of the form elements. This is where you define the form schema.

```
