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 ... in class Torann\GeoIP\GeoIP #62

Closed alariva closed 7 years ago

alariva commented 7 years ago

Hi,

After upgrading to 1.0.2 (btw, nice changes so far to see), I'm getting this error during tests:

Unresolvable dependency resolving [Parameter #0 [ <required> array $config ]] in class Torann\GeoIP\GeoIP

I've followed the upgrade guide, however I'm pretty sure I'm missing something.

I'm running Laravel 5.2 and you may find the current state of my project (broken) in this branch

Thanks in advance for your support!

Torann commented 7 years ago

Sounds like you aren't calling GeoIP correctly. If you are using the facade you need to update your config/app.php file to the new namespace:

'GeoIP'      => \Torann\GeoIP\Facades\GeoIP::class,

Also here https://github.com/timegridio/timegrid/blob/b45513ed851e6b3b3aa1f9b11d8d9a8ae00e219f/app/TG/DetectTimezone.php#L13 should look more like this:

    public function __construct()
    {
        $this->geoip = app('geoip');

        $this->detect();
    }

You can also use the helper function geoip() to get the GeoIP instance.

alariva commented 7 years ago

Thanks @Torann for the hints.

For the record: So I got the production code changed as well as tests, and I'm not sure if I'm getting this the way it should be, but having the tests pass seem to be a good starting point.

https://travis-ci.org/timegridio/timegrid/builds/168768522