Skip to content
Ben Claar edited this page Mar 2, 2016 · 18 revisions

Installation

Require Former package using Composer:

composer require anahkiasen/former   # For Laravel 4, use anahkiasen/former:~3.5

Then run "composer update". Next modify your config/app.php. In the providers array add :

Former\FormerServiceProvider::class

Add then alias Former's main class by adding its facade to the aliases array in the same file :

'Former' => 'Former\Facades\Former',

Modifying Former's config file

Simply do php artisan config:publish anahkiasen/former

Outside of a framework

Add Former to your Composer file. Then do this :

use Former\Facades\Former;

And you're done.

Quick Start Guide

Former is to be used as a View helper – meaning it provides for you a class that you can use directly in your views to output HTML code.

<?= Former::open()->method('GET') ?>
	<?= Former::text('name')->required() ?>
<?= Former::close() ?>

If you're using Twig or other more closed view templating systems, you can still use Former's classes outside :

$form = (string)Former::open()->method('GET');
	$form .= Former::text('name')->required();
$form .= Former::close();

Former uses a fluent interface for building up form objects. Former objects don't actually function until they are cast to a string or ->render()'d.

Clone this wiki locally