PRS-17 error on geocoding
trippo opened this issue · 5 comments
No PSR-17 response factory found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation
@trippo Please provide more information. You haven't explained what you expect, what you think is wrong, or provided anything for us to help you with. Please provide your geocoded config file, and the complete stack-trace of the error from your log.
Guessing from what you posted here, you have not implemented the config file properly, and have not included a proper HTTP layer in your composer.json.
By default the package uses the CURL client, but if you aren't using that, you will need to add your own, like Guzzle, etc...
OK geocoder.php
`use Geocoder\Provider\Chain\Chain;
use Geocoder\Provider\GeoPlugin\GeoPlugin;
use Geocoder\Provider\BingMaps\BingMaps;
use Geocoder\Provider\FreeGeoIp\FreeGeoIp;
use Http\Client\Curl\Client;
return [
/*
|--------------------------------------------------------------------------
| Cache Duration
|--------------------------------------------------------------------------
|
| Specify the cache duration in seconds. The default approximates a forever
| cache, but there are certain issues with Laravel's forever caching
| methods that prevent us from using them in this project.
|
| Default: 9999999 (integer)
|
/
'cache-duraction' => 999999999,
/
|--------------------------------------------------------------------------
| Providers
|--------------------------------------------------------------------------
|
| Here you may specify any number of providers that should be used to
| perform geocaching operations. The chain provider is special,
| in that it can contain multiple providers that will be run in
| the sequence listed, should the previous provider fail. By
| default the first provider listed will be used, but you
| can explicitly call subsequently listed providers by
| alias: app('geocoder')->using('google_maps').
|
| Please consult the official Geocoder documentation for more info.
| https://github.com/geocoder-php/Geocoder#providers
|
/
'providers' => [
Chain::class => [
GoogleMaps::class => [
'en-US',
env('GOOGLE_MAPS_API_KEY'),
],
BingMaps::class => [
'en-US',
env('BING_MAPS_API_KEY'),
],
GeoPlugin::class => [],
FreeGeoIp::class => [],
]
],
/
|--------------------------------------------------------------------------
| Adapter
|--------------------------------------------------------------------------
|
| You can specify which PSR-7-compliant HTTP adapter you would like to use.
| There are multiple options at your disposal: CURL, Guzzle, and others.
|
| Please consult the official Geocoder documentation for more info.
| https://github.com/geocoder-php/Geocoder#usage
|
| Default: Client::class (FQCN for CURL adapter)
|
/
'adapter' => Client::class,
/
|--------------------------------------------------------------------------
| Reader
|--------------------------------------------------------------------------
|
| You can specify a reader for specific providers, like GeoIp2, which
| connect to a local file-database. The reader should be set to an
| instance of the required reader class.
|
| Please consult the official Geocoder documentation for more info.
| https://github.com/geocoder-php/geoip2-provider
|
| Default: null
|
*/
'reader' => null,
];
`
Code i call:
$searchData = Geocoder::geocode('Via Val Rossia, 22, valdagno, 36078')->get()->first(); if($searchData){ $addressLat = $searchData->getCoordinates()->getLatitude(); $addressLng = $searchData->getCoordinates()->getLongitude(); pr($addressLat); pr($addressLng); }
On my localhost and dev server all work fine but on production server there is this problem.
Where can I find the complete stack-trace of the error ?
You can 'fix' this by using the Guzzle HTTP Adapter:
composer require php-http/guzzle6-adapter
Then in app\config\geocoder.php:
'adapter' => \Http\Adapter\Guzzle6\Client::class,Thanks this solve this issue
