alexpechkarev / google-geocoder

Google Geocoder API v3 for Laravel
MIT License
74 stars 13 forks source link

Configs #2

Closed unixtime closed 9 years ago

unixtime commented 9 years ago

Trying to test this package, I guess I am missing a step. I created the config file under the config directory based on the provided instructions. Somehow Laravel 5 is complaining about the config file.

Unresolvable dependency resolving [Parameter #0 [  $config ]] in class Alexpechkarev\GoogleGeocoder\GoogleGeocoder

Here is the controller function I have.

use Alexpechkarev\GoogleGeocoder\GoogleGeocoder;
-----
 public function DisplayAddress(GoogleGeocoder $request)
    {
        $value = $request->geocode('json', array("latlng"=>"40.714224,-73.961452"));

        return $value;
    }

Any idea? Thanks.

alexpechkarev commented 9 years ago

Hi Hassan,

In Laravel 5 please create config file in app folder app/google-geocoder.php, copy file contents. Register service provider in app/config.php and then simply call Geocoder:

$param = array("address"=>"76 Buckingham Palace Road London SW1W 9TQ"); $response = \Geocoder::geocode('json', $param);

Please note back slash \Geocoder. In your case try:

public function DisplayAddress(\GoogleGeocoder $request) { ... }

and I think you do not need to import Geocoder as it booted in service providers and available globally in your app.

Hope this helps. Regards, Alexander

unixtime commented 9 years ago

Thanks Alex. I had the config file in the wrong place.