lumen-generators
lumen-generators copied to clipboard
Undefined variable app in web.php Lumen 5.5
Routes/web.php
$app->get('task', 'TasksController@all'); $app->get('task/{id}', 'TasksController@get'); $app->post('task', 'TasksController@add'); $app->put('task/{id}', 'TasksController@put'); $app->delete('task/{id}', 'TasksController@remove');
resolved by changing $app to router.
There is an option: --laravel
This will do the trick, when generating route :)
Hi there,
When using --laravel I get an error saying that option doesn't exist
Hi @seagyn,
this feature comes with verison 1.3.4: https://github.com/webNeat/lumen-generators/releases/latest
@wdj-ac I'm using 1.3.4?
really? I mean, it will just use an other template to generate routes (see above). You could check your files if everything is present fot it: https://github.com/webNeat/lumen-generators/commit/a2cf22d4261b4641e3ed55eab5d2e8cc1663a963
Yeah, really. Looked and it's not there. composer.lock:
{
"name": "wn/lumen-generators",
"version": "1.3.4",
I'm just manually doing it but thought it would be useful to know as it didn't solve the issue of this issue.
I have the version 1.3.4 and steel the error: Undefined variable: app Before delete all routes can run again the command. I doing this process every time. I hope can you fix this in the next version.
Hey guys, I was able to resolve this with just a temporary solution only. In my case, I was using Lumen 5.5 and the issue is triggered by the $app variable found in routes/web.php.
This $app var is not recognized by Lumen because web.php uses the $router var instead. As a temporary solution, you can replace all the $app var generated by this generator to $router.
Please note though, that this variable might change depending on the version and if whether you're using Laravel or Lumen. Anyways, I hope this would be helpful to anyone!
NOTE: This is just a temporary solution. If time permits, I'll try to dig into the code and see if I can make a more permanent solution. Thanks!
so i got this error too, and i figure a way to solve it in Laravel 5.5 and above.
In your Application folder, Visit this path /vendor/wn/lumen-generators/templates/routes.wnt
Change all app to router here
Save and use the command line.
It will automatically Generate the routes using $router.
I should create a PR to him to solve this