I've installed Geofield and GeoPHP modules and I'm getting this error after I have save added the Geofield to my content type. I get the following error.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class '\geoPHP' not found in Drupal\geofield\GeoPHP\GeoPHPWrapper->load() (line 18 of modules\geofield\src\GeoPHP\GeoPHPWrapper.php).
Drupal\geofield\GeoPHP\GeoPHPWrapper->load('POINT (7.1101 52.2593)') (Line: 206)
Drupal\geofield\Plugin\Field\FieldType\GeofieldItem->populateComputedValues() (Line: 199)
Drupal\geofield\Plugin\Field\FieldType\GeofieldItem->setValue(Array, ) (Line: 69)
Drupal\Core\TypedData\Plugin\DataType\ItemList->setValue(Array, 1) (Line: 118)
Drupal\Core\Field\FieldItemList->setValue(Array) (Line: 373)
Drupal\Core\Field\WidgetBase->extractFormValues(Object, Array, Object) (Line: 222)
Drupal\Core\Entity\Entity\EntityFormDisplay->extractFormValues(Object, Array, Object) (Line: 223)
Drupal\Core\Entity\ContentEntityForm->copyFormValuesToEntity(Object, Array, Object) (Line: 291)
Drupal\Core\Entity\EntityForm->buildEntity(Array, Object) (Line: 74)
Drupal\Core\Entity\ContentEntityForm->buildEntity(Array, Object) (Line: 94)
Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 83)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 270)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'node_place_form') (Line: 119)
Drupal\Core\Form\FormValidator->validateForm('node_place_form', Array, Object) (Line: 569)
Drupal\Core\Form\FormBuilder->processForm('node_place_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('node_place_form', Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 113)
Drupal\node\Controller\NodeController->add(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 139)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 98)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Any ideas?

Thanks

Comments

Raher created an issue. See original summary.

darren.fisher’s picture

Hi,

We're experiencing this exact same issue. @Raher did you manage to resolve this?

Regards,

Darren.

Ewout Goosmann’s picture

Hello,

We are also encountered this warning. Is there already a solution?

texas-bronius’s picture

I don't know either, but I'm wondering if someone can confirm that it /should/ work and whether it's one of these "composer issues" and how the module is supposed to be installed?

gdelver@xs4all.nl’s picture

@texas-bronius: #4: FYI: I got the following stack working in 8.1.x with composer commands:

composer config repositories.drupal composer https://packages.drupal.org/8
composer require drupal/geofield 1.0-alpha2
composer require drupal/geocoder 2.0-alpha4
composer require drupal/address 1.x-dev
composer require drupal/styled_google_map 2.0-alpha1

you need a google map key ...

I am now in the process of testing geolocation which works fine too...

cheers, Guido

texas-bronius’s picture

Thanks Guido - You beat me to it (and provided a way better response than I would have). But did you not need composer require "phayes/geophp"? That's what did the trick for me..

gdelver@xs4all.nl’s picture

@texas-bronius #6,

It was loaded by composer, look at the difference in versions:I use:
composer require drupal/geofield 1.0-alpha2
see also documentation in the beginning of https://www.drupal.org/project/geofield on drupal 8 and geophp dependency

and ... you need a google map key ...!

have fun ;-), Guido

NicolasH’s picture

Version: 8.x-1.0-alpha1 » 8.x-1.0-alpha4

I'm still getting this in alpha4.

bronk’s picture

Also still getting this in the alpha. Why is it trying to load the geoPHP class if it's not relying on it anymore?

rmcdahal’s picture

I am thinking Why i have choose this module over geolocation module.. Opened issue no response,no fix..

imclean’s picture

@bronk geoPHP is the library https://github.com/phayes/geoPHP . The module GeoPHP provides Drupal integration with the library. This can get a bit confusing when using the Geocoder module. #2925674: Geocoder and GeoPHP modules

Mile23’s picture

This happens because phayes/geoPHP does not (correctly) specify how to autoload classes in its composer.json file.

There are a bunch of issues and PRs for that project about this, but I like mine the best: https://github.com/phayes/geoPHP/pull/147

itamair’s picture

The Geofield Module for Drupal 8 is NOT depending from the Drupal GeoPHP module anymore
but directly REQUIRE the GeoPHP library.
The correct method is to install the Geofield module via composer:

composer require drupal/geofield

that (if your root composer.json is properly setup for your D8 installation) will correctly download the geoPHP too, in the vendor/phayes/geophp folder
Otherwise you will need to run (anyway, at least):

composer require phayes/geophp

to fix this issue, as stated in the #6

Mile23’s picture

I've done all that and I still get this when I try to save a new field:

Fatal error: require(): Failed opening required '/srv/bindings/a59a1de20acf437992562ac05f8fbdd8/code/vendor/composer/../phayes/geophp/geoPHP.inc' (include_path='.:/usr/share/pear:/usr/share/php') in /srv/bindings/a59a1de20acf437992562ac05f8fbdd8/code/vendor/symfony/class-loader/ApcClassLoader.php on line 110

This is on Pantheon.

Here's what it looks like locally for my site:

$ composer show */geophp
phayes/geophp dev-master 6855624 GeoPHP is a open-source native PHP library...
itamair’s picture

@Mile23 it would probably depend on where your "composer require phayes/geophp" is installing and looking for the geophp library.
It seems it is searching it in a very pantheon env specific location, and might depend on the proper way pantheon is asking you to add D8 modules/requirements, and its composer.json.

In any of the standard D8 ways to install D8 with composer (Option A, B, or C) each of the following commands:

composer require drupal/geofield

composer require phayes/geophp

would create this folder: /vendor/phayes/geophp
and the autoload should be able to find the proper geophp files/classes, when called from the geofield module, and that's it.

Some matter on your specific dev env and/or way to install otherwise ...

itamair’s picture

If you have great (and insurmountable problems) using Composer to download / updates your D8 requirements,
you may try this tool (free now): https://composy.io
to create and download your working environment locally, test that everything works properly and even take advantage of the contextually created composer.json ...

itamair’s picture

Status: Active » Closed (works as designed)
oheller’s picture

I have the module installed using composer require drupal/geofield. I found that after using pantheon auto updates I had to run composer dump-autoload. To be warned I also had a permission issue that I need to resolve with the vendor/composer/autoload_psr4.php.