laravel class not found - Class 'GoogleMaps' not found

1.8k views Asked by At

I am using https://github.com/alexpechkarev/google-maps package with laravel 5.4 to create a google map and get driving distance from one point to another, But When i call this function,

Symfony \ Component \ Debug \ Exception \ FatalThrowableError
(E_ERROR)    Class 'GoogleMaps' not found

d

$d['a'] = \GoogleMaps::load('geocoding')
        ->setParamByKey('place_id', 'ChIJd8BlQ2BZwokRAFUEcm_qrcA')
        ->get();

I have installed the package via

composer require alexpechkarev/google-maps:1.0.8

and added aliases,'providers' in config/app.php

'providers' => [
    ...
    'GoogleMaps\ServiceProvider\GoogleMapsServiceProvider',
]

'aliases' => [
    ...
    'GoogleMaps' => 'GoogleMaps\Facade\GoogleMapsFacade',
]

why am i getting this error,Cannot find a way around it,Does anybody have an answer

1

There are 1 answers

0
5less On

You are registering the providers and alias wrong. Try this in config/app.php

'providers' => [
    GoogleMaps\ServiceProvider\GoogleMapsServiceProvider::class,
]

'aliases' => [
    'GoogleMaps' => GoogleMaps\Facade\GoogleMapsFacade::class,
]