geocoder-php / Geocoder

The most featured Geocoder library written in PHP.
https://geocoder-php.org
MIT License
3.95k stars 519 forks source link

Puli Factory is not available exception #847

Closed ghost closed 5 years ago

ghost commented 6 years ago

Hi, I'm using the latest version of Geocoder:

"geocoder-php/google-maps-provider": "^4.2",
"php-http/guzzle6-adapter": "^1.1",
"php-http/message": "^1.6"
$httpClient = new \Http\Adapter\Guzzle6\Client();
$provider = new \Geocoder\Provider\GoogleMaps\GoogleMaps($httpClient, 'my region', 'my key');

The second line (initing new instance of provider) always throws an exception:


Http\Discovery\Exception\PuliUnavailableException: Puli Factory is not available in PATH\vendor\php-http\discovery\src\Strategy\PuliBetaStrategy.php on line 39
--
1 | 0.4011 | 381408 | {main}( ) | ...\index.php:0
2 | 0.4092 | 805824 | handle ( ) | ...\index.php:39
3 | 0.4132 | 1061224 | dispatch ( ) | ...\index.php:39
4 | 0.4230 | 1646760 | callActionMethod ( ) | ...\index.php:39
5 | 0.4230 | 1647048 | Site\Controllers\OrderController->processAction( ) | ...\index.php:39
6 | 0.4444 | 2180112 | Common\Models\Orders->setDelivery( ) | ...\OrderController.php:113
7 | 0.4448 | 2186112 | Common\Library\Services\Delivery->setProvider( ) | ...\Orders.php:301
8 | 0.4473 | 2229304 | Common\Library\Services\Delivery\Providers\CourierDelivery->setData( ) | ...\Delivery.php:23
9 | 0.4483 | 2245416 | Common\Library\Services\Delivery\Providers\CourierDelivery->getAddressRaw( ) | ...\CourierDelivery.php:22
10 | 0.4556 | 2753000 | Geocoder\Provider\GoogleMaps\GoogleMaps->__construct( ) | ...\CourierDelivery.php:30
11 | 0.4556 | 2753000 | Geocoder\Provider\GoogleMaps\GoogleMaps->__construct( ) | ...\GoogleMaps.php:99
12 | 0.4562 | 2775280 | Http\Discovery\MessageFactoryDiscovery::find( ) | ...\AbstractHttpProvider.php:46
13 | 0.4562 | 2775280 | Http\Discovery\ClassDiscovery::findOneByType( ) | ...\MessageFactoryDiscovery.php:25
14 | 0.4562 | 2775360 | call_user_func:{S:\Server\www\linza.com.ua\vendor\php-http\discovery\src\ClassDiscovery.php:54} ( ) | ...\ClassDiscovery.php:54
15 | 0.4568 | 2785456 | Http\Discovery\Strategy\PuliBetaStrategy::getCandidates( ) | ...\ClassDiscovery.php:54
16 | 0.4568 | 2785456 | Http\Discovery\Strategy\PuliBetaStrategy::getPuliDiscovery( ) | ...\PuliBetaStrategy.php:79
17 | 0.4568 | 2785456 | Http\Discovery\Strategy\PuliBetaStrategy::getPuliFactory( ) | ...\PuliBetaStrategy.php:64

PHP v7.1.13

Nyholm commented 6 years ago

Hey.

You get some more exception output that this, right? I would say that you have not installed php-http/message and/or php-http/guzzle6-adapter. Because if you have, the php-http/discovery would find classes for you.

ghost commented 6 years ago

Nope, I have only one "Puli Factory is not available ..." exception.

I have installed via composer php-http/message and php-http/guzzle6-adapter like in the geocoder installation guide:

$ composer require geocoder-php/google-maps-provider php-http/guzzle6-adapter php-http/message

I can see this library in the composer.lock and in the vendor folder. I have the following versions installed:

geocoder-php/google-maps-provider v4.2.0 php-http/guzzle6-adapter v1.1.1 php-http/message 1.6.0

Also, geocoder works despite the exception. Geocoder returns data response from google and throwing the exception.

pls check the screenshot

Nyholm commented 6 years ago

That is super weird. I know that Magento users has this issue (long story but the bug is at Magento's) and I know this issue existed before 1.0 of php-http/discovery.

It is fine that this exception is being thrown but it should be caught within the php-http/discovery library

garak commented 6 years ago

I'm getting the same exception (sadly, in production only) with following installed deps

geocoder-php/common-http 4.1.0 geocoder-php/google-maps-provider 4.2.0 kriswallsmith/buzz v0.15.2 php-http/buzz-adapter 1.0.0 php-http/message 1.7.0 willdurand/geocoder 4.2.0

Nyholm commented 5 years ago

The exception message has been improved in php-http/discovery 1.5