14

I'm using Lumen, the Laravel recently new micro framework.

I was searching for a form builder and I found Former :

http://anahkiasen.github.com/former/

I put in a simple blade view the following code :

use Former\Facades\Former;

echo Former::open()->method('GET');
    echo Former::text('name')->required();
echo Former::close();

and I get the following error :

ErrorException in Container.php line 776:Class former does not exist (View: ...)

so I added the ServiceProvider to my app.php :

$app->register('Former\FormerServiceProvider');

and I get the following error :

Fatal error: Call to undefined method Illuminate\Config\Repository::package() in D:\...\vendor\anahkiasen\former\src\Former\FormerServiceProvider.php on line 147

My question is : how can I get it done with Lumen? At worse, how can I get a good form builder lib with Lumen?

MANY thanks in advance

Alexis Romot
  • 524
  • 6
  • 19

2 Answers2

0

did you get the 4.0 branch, in Laravel 5 Illuminate\Config\Repository class has no method called package (http://laravel.com/api/5.0/Illuminate/Config/Repository.html)

Since Lumen uses illuminate/config 5.0.* you should get 4.0 branch for form builder. (https://github.com/formers/former#for-laravel-5-use-the-40-branch)

engvrdr
  • 541
  • 2
  • 9
  • Yes, I wasn't using the 4.0 branch. I've chenged it. Now I'm using the 4.0 and I get the following error : ReflectionException in Container.php line 776: Class path.config does not exist – Alexis Romot Apr 22 '15 at 11:25
0

This composer.json configuration seems works in my App.

"repositories": [
    {
        "type": "git",
        "url": "https://github.com/formers/former.git"
    }
],
"require": {
    "laravel/lumen-framework": "5.0.*",
    "vlucas/phpdotenv": "~1.0",
    "anahkiasen/former": "4.0.x-dev"
},

After do:

composer update -vvv

I update my bootstrap/app.php:

/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
|
| Here we will register all of the application's service providers which
| are used to bind services into the container. Service providers are
| totally optional, so you are not required to uncomment this line.
|
*/

// $app->register('App\Providers\AppServiceProvider');
$app->register('Former\FormerServiceProvider');

Testing in app/Http/routes.php:

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use Former\Facades\Former;

$app->get('/', function() use ($app) {
    echo Former::open()->method('GET');
        echo Former::text('name')->required();
    echo Former::close();
});

Output:

<form accept-charset="utf-8" class="form-horizontal" method="GET">
    <div class="form-group required">
        <label for="name" class="control-label col-lg-2 col-sm-4">Name<sup>*</sup></label>
        <div class="col-lg-10 col-sm-8">
            <input class="form-control" required="true" id="name" type="text" name="name">
        </div>
    </div>
</form>

All seems works well. I think the problem is outdated packages.

Update

I change my app/Http/routes.php into something like this:

$app->get('/', function() use ($app) {
    return view('foo');
});

And this is my foo.blade.php:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Foo</title>
</head>
<body>
    {!! Former\Facades\Former::open()->method('GET'); !!}
        {!! Former\Facades\Former::text('name')->required(); !!}
    {!! Former\Facades\Former::close(); !!}
</body>
</html>

And it works.

krisanalfa
  • 6,268
  • 2
  • 29
  • 38