geocoder-php/GeocoderLaravel

Call to undefined function Geocoder\Laravel\cache()

imail2pankaj opened this issue · 10 comments

General Information

GeocoderLaravel Version: 3.3
Laravel Version: 5.1
PHP Version: 7.0.18
Operating System and Version: ubuntu0.16.04.1

Hello @willdurand, @K-Phoen I have installed GeocoderLaravel version "stable" and I am getting below. This error when using geocoder. I was not getting any error when I was using earlier version of Geocoder

Here is the error I am getting
FatalThrowableError in /var/www/*****/vendor/toin0u/geocoder-laravel/src/ProviderAndDumperAggregator.php line 78: Call to undefined function Geocoder\Laravel\cache()

I am using Laravel 5.1 and Package using cache() function, but when I use Cache::remember() it works perfectly for me. Is it possible that Laravel 5.1 does not support cache() function? cache() functions is not showing when I checked Cache in 5.1 and 5.2, but showing in 5.3 and 5.4.

So can we use Cache class instead of cache() in all laravel 5.* versions?

Hi @imail2pankaj , can you provide the full geocode code snippet you are trying to run, along with the full stack trace of the error? I will try and see what’s going on.

Confirmed this is happening as well in version 1. I am using Lumen so that might be a factor

@prog-24 Can you provide the snippet of code you are trying to run, as well as a stack trace?

I think I identified the issue. Could you guys give it another shot with version 1.1.2?

Here is the Code Snippet I have used.

    protected function geoCodeAddress(CourseRequest $request) {
        if (!$request->has('street_address') || !$request->has('city') || !$request->has('state') || !$request->has('zip')) {
            return false;
        }
        try {
            return Geocoder::geocode($request->get('street_address') . ', ' . $request->get('city') . ' United States ' . $request->get('zip'))->get()->first();
        } catch (\Exception $e) {
            return false;
        }
    }

Please let me know how version 1.1.2 works for you.

I couldn't download version 1.1.2 but the latest version I have: 1.x-dev a322da3, the issue seems to be fixed

Here is the composer definition: "toin0u/geocoder-laravel": "^1.2"

@prog-24 Thanks for the feedback. What error were you getting when you tried to install version 1.1.2? The commit you reference above is correct. Packagist does list 1.1.2 as available, so it should work. Try composer clear-cache then composer update to download "toin0u/geocoder-laravel": "1.*"

I didnt receive any, I was just given the dev version. The composer definition fixed it. Thanks

Awesome! Thanks for helping out troubleshooting and reporting this issue. Closing now, as it seems fixed.