Anahkiasen / former developer of lib forms for Lumen / (Laravel microstructure)

I am using Lumen, the recently created new Laravel framework.

I was looking for a form constructor and I found Former:

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

I put the following code to a simple blade:

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 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 do this with Lumen? In the worst case, how can I get a good form constructor with Lumen?

MANY thanks in advance

+7
php laravel lumen
source share
2 answers

You got branch 4.0, in Laravel 5 Illuminate \ Config \ Repository the class does not have a method called a package ( http://laravel.com/api/5.0/Illuminate/Config/Repository.html )

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

0
source share

This composer.json configuration seems to work in my application.

 "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 that do:

 composer update -vvv 

I am updating my bootstrap/app.php :

 /* |-------------------------------------------------------------------------- | Register Service Providers |-------------------------------------------------------------------------- | | Here we will register all of the application 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 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> 

Everything looks good. I think the problem is outdated packages.

Update

I am changing my app/Http/routes.php to 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.

0
source share

All Articles