Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined variable app in web.php Lumen 5.5 #51

Open
cedcraftscodes opened this issue Nov 14, 2017 · 9 comments
Open

Undefined variable app in web.php Lumen 5.5 #51

cedcraftscodes opened this issue Nov 14, 2017 · 9 comments

Comments

@cedcraftscodes
Copy link

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.

@nightillusions
Copy link

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

@seagyn
Copy link

seagyn commented Jan 29, 2018

Hi there,

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

@nightillusions
Copy link

Hi @seagyn,

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

@seagyn
Copy link

seagyn commented Jan 29, 2018

@wdj-ac I'm using 1.3.4?

@nightillusions
Copy link

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:
a2cf22d

@seagyn
Copy link

seagyn commented Jan 29, 2018

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.

@gemins
Copy link

gemins commented Feb 19, 2018

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.

@byronalfonso
Copy link

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!

@bunday
Copy link

bunday commented Mar 18, 2018

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

j-mastr added a commit to itsmindcom/lumen-generators that referenced this issue Nov 10, 2018
Also change back to $router in templates for webNeat#51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants