Torann / laravel-geoip

Determine the geographical location of website visitors based on their IP addresses.
http://lyften.com/projects/laravel-geoip
BSD 2-Clause "Simplified" License
2.09k stars 372 forks source link

Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\ServiceProvider #78

Closed selim-mahmud closed 5 years ago

selim-mahmud commented 7 years ago

I have installed Laravel Geoip package in my laravel 5.3 project. When I use geoip() helper function, it working fine. But, when I use Torann\GeoIP\GeoIP, its showing following error:

Unresolvable dependency resolving [Parameter #0 [ $app ]] in class Illuminate\Support\ServiceProvider

Torann commented 7 years ago

Sounds like it's not being added to you service provider config file. Did you follow the install directions?

http://lyften.com/projects/laravel-geoip/doc/

hackel commented 6 years ago

I just ran into this issue myself after upgrading. You can't inject Torann\GeoIP\GeoIP directly. You need to use the abstract 'geoip' that properly supplies the configuration parameters. I recommend adding this to your AppServiceProvider::register:

$this->app->alias('geoip', \Torann\GeoIP\GeoIP::class);

This way you will be able to inject the configured instance properly wherever you want to use it.