using the $app object inside a controller (Lumen) -


ok im farly new lumen , laravel , im trying make api https://packagist.org/packages/codenexus/lumen-geoip work in lumen, installed via composer , im able use , obtain locations based on ip given when im inside routes.php

but when i'm using same code inside controller doesnt let me proceed cause $app variable not defined.

this code works inside routes

    $app->geoip->getlocation('148.210.21.180')->country->names['en'] 

i have been reading service container me in solution feel lost... in advice help.

the $app variable not available inside controllers, may use app() method anywhere in code access application object.

so, try in controller:

app()->geoip->getlocation('148.210.21.180')->country->names['en'] 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

post - imageshack API cURL -

dataset - MPAndroidchart returning no chart Data available -