1

I installed the geocoder-php composer package using php composer.phar install. I'm running on PHP framework Laravel.

Loading composer repositories with package information
Installing dependencies
  - Installing willdurand/geocoder (1.0.10)
    Downloading: 100%

  - Installing kriswallsmith/buzz (v0.7)
    Downloading: 100%

willdurand/geocoder suggests installing guzzle/guzzle (Enabling Guzzle allows you to use the GuzzleHttpAdapter.)
willdurand/geocoder suggests installing zendframework/zend-http (Enabling Zend_Http allows you to use the ZendHttpAdapter)
Writing lock file
Generating autoload files

paths.php

// --------------------------------------------------------------
// The path to the composer vendors directory.
// --------------------------------------------------------------
$paths['composer'] = 'vendor';

public/index.php

// --------------------------------------------------------------
// Autoload composer vendors.
// --------------------------------------------------------------
require path('composer').DS.'autoload.php';

composer.json

{
    "require": {
        "willdurand/geocoder": "@stable",
        "kriswallsmith/buzz": "@stable"
    }
}

Problem: I get the following error when I try to run the example on Geocoder-php's homepage:

Error:

Class 'Geocoder\HttpAdapter\BuzzHttpAdapter' not found

Occurs at:

$adapter  = new \Geocoder\HttpAdapter\BuzzHttpAdapter();

Directory structure

enter image description here

I have already installed Buzz, did I miss out something?

Nyxynyx
  • 61,411
  • 155
  • 482
  • 830

1 Answers1

1

You need to require the autoloader before it can work

Try adding the following :

require 'vendor/willdurand/Geocoder/autoload.php';
Baba
  • 94,024
  • 28
  • 166
  • 217
  • Tried it but still getting an error. Using `require vendor/willdurand/Geocoder/src/autoload.php` gave the error `Class 'Buzz\Browser' not found` – Nyxynyx Sep 24 '12 at 00:23
  • Do you have another autoloader in your script – Baba Sep 24 '12 at 00:28
  • 1
    That is the only autoloader in the `Geocoder` package. However I can get it to work if I do a `require path('composer').'autoload.php';` from within the function that uses the Geocoder class. Could this be an issue with the Laravel framework? – Nyxynyx Sep 24 '12 at 00:31
  • Am not very sure .. i would look around and get back to you – Baba Sep 24 '12 at 00:39
  • 1
    Cool .... Well done .. you where have 2 auloader as suspected , one in Geocoder another in Laravel framework – Baba Sep 24 '12 at 00:41
  • btw why dont you use the curl adapter, seems the easiest for me because on board? – Timo Jun 17 '14 at 17:42