geocoder-php / GeocoderLaravel

Geocoder service provider for Laravel
http://geocoder-php.org/GeocoderLaravel/
MIT License
704 stars 102 forks source link

Allow passing reader class and arguments as array #164

Closed tooblue closed 5 years ago

tooblue commented 5 years ago

Laravel does not support closures within the config files (https://github.com/laravel/framework/issues/9625), and so setting the geocoder.reader configuration to an instance of \GeoIp2\Database\Reader or \GeoIp2\WebService\Client created problems when running php artisan config:cache.

With the changes I made, you could configure the reader like so:

    'reader' => [
        'class' => WebService::class,
        'arguments' => [env('MAXMIND_USER_ID'), env('MAXMIND_LICENSE_KEY')],
    ],

It also still supports the old method of setting the reader instance:

    'reader' => new WebService(
        env('MAXMIND_USER_ID'),
        env('MAXMIND_LICENSE_KEY')
    ),
coveralls commented 5 years ago

Coverage Status

Coverage decreased (-1.2%) to 89.764% when pulling dde4def85d6269b27a1fbf360e188a210e1133a7 on tooblue:patch-1 into 67f027b23654e62f62d489c66fd4cc4a5baa8a6a on geocoder-php:master.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-1.2%) to 89.764% when pulling dde4def85d6269b27a1fbf360e188a210e1133a7 on tooblue:patch-1 into 67f027b23654e62f62d489c66fd4cc4a5baa8a6a on geocoder-php:master.

mikebronner commented 5 years ago

@tooblue Good PR! Thanks :) I'll take a look at this over the next day or so. :)

mikebronner commented 5 years ago

@tooblue Could you give release 4.2.4 a try and let me know if it works for you?

tooblue commented 5 years ago

@mikebronner That works! Thanks very much. :)

mikebronner commented 5 years ago

Awesome! :) I changed the syntax around a bit to better match the other array-notations. Thanks for your work on this! :)