lumen-generators icon indicating copy to clipboard operation
lumen-generators copied to clipboard

Undefined variable app in web.php Lumen 5.5

Open cedcraftscodes opened this issue 8 years ago • 9 comments

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.

cedcraftscodes avatar Nov 14 '17 16:11 cedcraftscodes

There is an option: --laravel This will do the trick, when generating route :)

nightillusions avatar Jan 16 '18 17:01 nightillusions

Hi there,

When using --laravel I get an error saying that option doesn't exist

seagyn avatar Jan 29 '18 15:01 seagyn

Hi @seagyn,

this feature comes with verison 1.3.4: https://github.com/webNeat/lumen-generators/releases/latest

nightillusions avatar Jan 29 '18 15:01 nightillusions

@wdj-ac I'm using 1.3.4?

seagyn avatar Jan 29 '18 16:01 seagyn

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

nightillusions avatar Jan 29 '18 16:01 nightillusions

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.

seagyn avatar Jan 29 '18 16:01 seagyn

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.

gemins avatar Feb 19 '18 00:02 gemins

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!

byronalfonso avatar Mar 09 '18 07:03 byronalfonso

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

bunday avatar Mar 18 '18 07:03 bunday