mdailey77
mdailey77

Reputation: 2368

class from provider not loading in laravel 5.5

I want to use a service provider for the Google Geocoding API, https://github.com/jotafurtado/geocode in my Laravel 5.5 application. I followed the instructions, installed the provider using Composer. I had to manually add this line to the providers array in the config/app.php:

Jcf\Geocode\GeocodeServiceProvider::class

and then add this to the aliases array in the same file

'Geocode' => Jcf\Geocode\Facades\Geocode::class

When I call the Geocode class in my controller I get an error saying "Class 'App\Http\Controllers\Geocode' not found". Is there something I need to add to the controller or some command I need to run?

Upvotes: 0

Views: 463

Answers (2)

Sathishkumar
Sathishkumar

Reputation: 3733

You should use alias name to import the class like

use Geocode;

Laravel will resolve it for you by using alias name. That is the purpose of creating alias.

Upvotes: 0

jhnbrn
jhnbrn

Reputation: 231

Did you use an import statement at the top of your controller?

use Jcf\Geocode\Facades\Geocode;

Upvotes: 2

Related Questions