laravel class not found - Class 'GoogleMaps' not found - laravel

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

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,
]

Related

How to integrate smartystreet with laravel

I want to integrated smartystreets with my laravel project but am not able to do so.
I have tried this link , but it throw me error "Undefined constant 'FireEngineRed\SmartyStreetsLaravel\SmartyStreetsServiceProvider'" when i run "$ php artisan vendor:publish".
Any help would be appreciated.`
Change in step 2 of the above link worked for me:
change this:
'providers' => array(
...
'FireEngineRed\SmartyStreetsLaravel\SmartyStreetsServiceProvider',
)
'aliases' => array(
...
'SmartyStreets' => 'FireEngineRed\SmartyStreetsLaravel\SmartyStreetsFacade',
)
to this:
'providers' => [
...
FireEngineRed\SmartyStreetsLaravel\SmartyStreetsServiceProvider::class,
],
'aliases' => [
...
'SmartyStreets' = > FireEngineRed\SmartyStreetsLaravel\SmartyStreetsFacade::class,
],
Note:Add the SmartyStreets providers and aliases element at the end of the both array.

laravel 5.7 "Class 'Maatwebsite\Excel\ExcelServiceProvider' not found"

On my localhost is fine, but when i upload on my server i got this error:
"Class 'Maatwebsite\Excel\ExcelServiceProvider' not found"
My config/app.php:
'providers' => [
...
/*
* Package Service Providers...
*/
Maatwebsite\Excel\ExcelServiceProvider::class,
..
],
'aliases' => [
...
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
],
my laravel version is 5.7
Try running composer dump-autoload in your command line

Textarea in laravel 5.4

I have to print the reponse of API in textarea UI (blade.php) in laravel 5.4.
Tried doing:
{{ Form::textarea('response', '3 < 4') }}
But it gives the following error:
(1/1) FatalErrorException
Class 'Form' not found
What can I do to achieve this. In short I want an response textarea like it is in restclient.
Thanks !
You need to install Laravel FormCollective.
Run the following command from the Terminal: composer require "laravelcollective/html":"^5.2.0"
Next, add your new provider to the providers array of config/app.php:
'providers' => [
// ...
Collective\Html\HtmlServiceProvider::class,
// ...
],
Finally, add two class aliases to the aliases array of config/app.php:
'aliases' => [
// ...
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
// ...
],
Then, you can use {{ Form::textarea('response', '3 < 4') }} in your blade file!
Hope you understand!
The Form class is not a part of the default install of Laravel 5.
Please refer to installation here: https://laravelcollective.com/docs/master/html

Laravel Loading Service Provider and Alias

Maybe it is just me but im not sure what this do and why they need to do this?
in the providers that are loaded in laravel they did this
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
...
same for alias
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
...
What does the ::class do and why can't they just leave it off like this?
'aliases' => [
'App' => Illuminate\Support\Facades\App,
'Artisan' => Illuminate\Support\Facades\Artisan,
It just return class name with namespace !
Since PHP 5.5, the class keyword is also used for class name resolution.
You can get a string containing the fully qualified name of the ClassName class by using ClassName::class.
This is particularly useful with namespaced classes.
namespace NS {
class ClassName {
}
echo ClassName::class;
}
The above example will output:
NS\ClassName
Source 1
Php manual

Laravel 5 Form not found fatal error

I have done following process for resolving the error.
-I have added "illuminate/html": "5.*" to composer.json and ran "composer update"
-I have added following to config/app.php
'Illuminate\Html\HtmlServiceProvider',
'Form' => 'Illuminate\Html\FormFacade',
'Html' => 'Illuminate\Html\HtmlFacade',
- but my whole project is not working.Not running.It seems that it is composer issue.
Please help.
If i am correct the illuminate/html package isn't supported in laravel 5 anymore. There is a community fork at laravelcollective/html, see their site for all documentation.
You could swap the illuminate package for the laravelcollective package:
Add to your composer.json:
"require": {
"laravelcollective/html": "5.1.*"
}
Add provider to the providers array of config/app.php:
'providers' => [
Collective\Html\HtmlServiceProvider::class,
],
Add two class aliases to the aliases array of config/app.php:
'aliases' => [
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
],

Resources