diff --git a/README.md b/README.md index 4033cd7..e1fb912 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,10 @@ Find the `aliases` key in `app/config/app.php` and register the **Geocoder Facad Configuration ------------- +Publish the configuration + + $ php artisan config:publish toin0u\geocoder-laravel + The service provider creates the following services: * `geocoder`: the Geocoder instance. diff --git a/src/Toin0u/Geocoder/GeocoderServiceProvider.php b/src/Toin0u/Geocoder/GeocoderServiceProvider.php index 64dd0b2..69222c6 100644 --- a/src/Toin0u/Geocoder/GeocoderServiceProvider.php +++ b/src/Toin0u/Geocoder/GeocoderServiceProvider.php @@ -12,8 +12,6 @@ namespace Toin0u\Geocoder; use Geocoder\Geocoder; -use Geocoder\Provider\FreeGeoIpProvider; -use Geocoder\HttpAdapter\CurlHttpAdapter; use Illuminate\Support\ServiceProvider; /** @@ -36,7 +34,7 @@ class GeocoderServiceProvider extends ServiceProvider * @return void */ public function boot() { - $this->package('willdurand/geocoder'); + $this->package('toin0u/geocoder-laravel'); } /** @@ -49,11 +47,15 @@ public function register() $app = $this->app; $this->app['geocoder.adapter'] = $this->app->share(function() { - return new CurlHttpAdapter; + $adapter = \Config::get('geocoder-laravel::adapter'); + $class = 'Geocoder\HttpAdapter\\' . $adapter; + return new $class; }); $this->app['geocoder.provider'] = $this->app->share(function($app) { - return new FreeGeoIpProvider($app['geocoder.adapter']); + $provider = \Config::get('geocoder-laravel::provider'); + $class = '\Geocoder\Provider\\' . $provider; + return new $class($app['geocoder.adapter']); }); $this->app['geocoder'] = $this->app->share(function($app) { diff --git a/src/config/config.php b/src/config/config.php new file mode 100644 index 0000000..fdf8473 --- /dev/null +++ b/src/config/config.php @@ -0,0 +1,6 @@ +<?php + +return array( + 'provider' => 'FreeGeoIpProvider', + 'adapter' => 'CurlHttpAdapter' +);