-
Notifications
You must be signed in to change notification settings - Fork 106
ReflectionException: Class Chain does not exist #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for reporting this issue. I will take a look at this and re-run my unit tests to see what's going on. |
Your code is not actually performing the geocoding, only preparing it. To run the geocoding, use the <?php
public function reverse_geocode($lat, $lon) {
try {
$results = app('geocoder')->reverse($lat, $lon)->all();
foreach ($results as $result) {
app('db')->table('geocoded')->insert([
'type' => 'reverse',
'q' => $lat.','.$lon,
'lat' => $data['latitude'],
'lon' => $data['longitude'],
'coords' => \DB::raw("GeomFromText('POINT(".$data['longitude']." ".$data['latitude'].")')"),
'bounds' => json_encode($data['bounds']),
'street' => $data['streetNumber'] .' '.$data['streetName'],
'zip' => $data['zipcode'],
'city' => $data['city'],
'district' => $data['cityDistrict'],
'county' => $data['county'],
'region' => $data['region'],
'state' => $data['regionCode'],
'country' => $data['countryCode'],
'created_at' => new \Carbon\Carbon,
'updated_at' => new \Carbon\Carbon
]);
}
return $result;
} catch (\Exception $e) {
app('log')->error($e);
return false;
}
} (I like to use the app references instead of Facades, just a preference, not wrong if you use facades.) As always, if this issue persists, please re-open. :) Good luck! |
Thank you for the prompt and detailed response! Legend! |
Woot, glad to hear :) Please let me know if you have any feedback for Laravel Geocoder, improvements, or unexpected behavior. Always looking to improve and make it better. :) |
Just wanted to update this. The issue was because i was using an older version of the package, and the config file has been updated with the class namespaces. Package update didn't update config. |
Ah, that makes sense, since the config file is not automatically republished (and if you're not making any customizations to it, no need to publish it either). Thanks for reporting that back. Will add that as a to-do for documentation. |
General Information
GeocoderLaravel Version: 1.0.1
Laravel Version: 7.4
PHP Version: 7.1
Operating System and Version: Ubuntu 16
Issue Description
Can't reverse geocode because of Chain error.
Steps to Replicate
Function calling the package:
Stack Trace
Development.ERROR: ReflectionException: Class Chain does not exist in /srv/Demo.com/dev/vendor/toin0u/geocoder-laravel/src/Providers/GeocoderService.php:71
Stack trace:
#0 /srv/Demo.com/dev/vendor/toin0u/geocoder-laravel/src/Providers/GeocoderService.php(71): ReflectionClass->__construct('Chain')
#1 [internal function]: Geocoder\Laravel\Providers\GeocoderService->Geocoder\Laravel\Providers{closure}(Array, 'Chain')
#2 /srv/Demo.com/dev/vendor/laravel/framework/src/Illuminate/Support/Collection.php(684): array_map(Object(Closure), Array, Array)
#3 /srv/Demo.com/dev/vendor/toin0u/geocoder-laravel/src/Providers/GeocoderService.php(78): Illuminate\Support\Collection->map(Object(Closure))
#4 /srv/Demo.com/dev/vendor/toin0u/geocoder-laravel/src/Providers/GeocoderService.php(54): Geocoder\Laravel\Providers\GeocoderService->getProviders(Object(Illuminate\Support\Collection))
#5 /srv/Demo.com/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php(716): Geocoder\Laravel\Providers\GeocoderService->Geocoder\Laravel\Providers{closure}(Object(Illuminate\Foundation\Application), Array)
#6 /srv/Demo.com/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php(598): Illuminate\Container\Container->build(Object(Closure))
#7 /srv/Demo.com/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php(567): Illuminate\Container\Container->resolve('geocoder')
#8 /srv/Demo.com/dev/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(702): Illuminate\Container\Container->make('geocoder')
#9 /srv/Demo.com/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php(1139): Illuminate\Foundation\Application->make('geocoder')
#10 /srv/Demo.com/dev/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(159): Illuminate\Container\Container->offsetGet('geocoder')
#11 /srv/Demo.com/dev/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(128): Illuminate\Support\Facades\Facade::resolveFacadeInstance('geocoder')
#12 /srv/Demo.com/dev/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(215): Illuminate\Support\Facades\Facade::getFacadeRoot()
#13 /srv/Demo.com/dev/app/Http/Controllers/Front/BaseController.php(264): Illuminate\Support\Facades\Facade::__callStatic('reverse', Array)
#14 /srv/Demo.com/dev/app/Traits/GeoSearchHelper.php(364): Demo\Http\Controllers\Front\BaseController->reverse_geocode(43.6861, -79.4025)
The text was updated successfully, but these errors were encountered: