I've added
"laravel/socialite": "~2.0"
as a composer dependency, and i've added the service provider in my config/app.php just like this
'providers' => [
// more providers
'Laravel\Socialite\SocialiteServiceProvider'
]
Then, when i access to any of my application route, i've got this Class 'Laravel\Socialite\SocialiteServiceProvider' not found exception.
Looking into my vendor/composer/autoload_psr4.php i see there's not the Socialite mapping - ive ran composer update and composer dump-autoload more than once.
What's wrong?
Did you run the composer command before adding the provider to the file? If not, this can sometimes cause issues.
I recommend removing the reference from the config file and the composer.json, then running composer request laravel/socialite 2.0. Also, just fyi, using the ::class notation in the providers listing will help if you're using a full IDE like phpstorm, as it will highlight when it can't find the class.
I have removed the reference from the config file and the composer.json, then ran composer require laravel/socialite 2.0 instead of composer request laravel/socialite 2.0.
Then add the following lines to the config file
Laravel\Socialite\SocialiteServiceProvider::class,
and
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
first of all remove the line
Laravel\Socialite\SocialiteServiceProvider::class,
and also
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
from Config\app.php and update the composer by adding
"laravel/socialite": "^2.0" and after that add these two line in Config\app.php it will work because when you add these lines before updating composer it goes to vender folder and search for the SocialiteProvider but it is not available yet so when you will update composer first and then add these lines it will work fine
At first of all, check if your socialite package is compatible with your Laravel version.
You can verify your Laravel version inside your Laravel path, for it type:
$ php artisan --version
Then, check in the socialite Git repository (link below) a compatible version with your Laravel.
https://github.com/laravel/socialite/releases
Now install the socialite package with composer require laravel/socialite x.x (where x.x is your socialite choosed version)
Lastly add the following lines in config/app.php file
inside 'providers' => [
Laravel\Socialite\SocialiteServiceProvider::class,
and almost at the end of the file, inside 'aliases' => [
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
Save the file.
first of all you need to clear the cache of your project by this code
php artisan config:cache
and then you need to enter this code in the terminal (for facebook for example)
composer require socialiteproviders/facebook
in the previous line i ended it with facebook as an example but you could change it like instagram or anything else and the error will be solved
Related
I have installed dompdf/dompdf with version 0.8.1 package for my laravel 5.3.My question is what providers and aliases classes do i have to give in my config/app.php file.
I have given
Barryvdh\DomPDF\ServiceProvider::class,
and
'PDF' => Barryvdh\DomPDF\Facade::class,
But it showed error:
Class 'Barryvdh\DomPDF\ServiceProvider' not found.
The error is a different one. Your providers and aliases are fine. You need to run following code.
php artisan vendor:publish --provider="Barryvdh\DomPDF\ServiceProvider"
By running this command default configuration sets up.
You can find it on instruction of Barrvdh package installation [link]
When I run composer update, I get the following error:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Illuminate\Foundation\ComposerScripts::postUpdate
php artisan optimize
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Laravel\Cashier\CashierServiceProvider' not found
Script php artisan optimize handling the post-update-cmd event returned with err
or code 255
I put this code on the app.php file
Laravel\Cashier\CashierServiceProvider::class,
and in the composer.json I also put this
"laravel/cashier": "~6.0"
like in the laravel doc
stack errot
Remove the
Laravel\Cashier\CashierServiceProvider::class,
from app.php.
It needs to be added after installing the package.
Also, instead of composer update, try composer require without changing the composer.json file.
composer require laravel/cashier
Don't add anything in composer.json file or app.php.
Just follow the documentation given in Laravel website for Laravel Cashier, (select the laravel version which you are using in your project).
Run the commands in following order:
//install the package and add it in composer file
composer require laravel/cashier
//add your cashier class in 'providers' array in app.php
Laravel\Cashier\CashierServiceProvider::class,
//add alias in 'aliases' array in app.php
'Cashier' => Laravel\Cashier\CashierServiceProvider::class,
//will add several columns to users table & create a new subscriptions table
php artisan migrate
Check the php version in cmd useing php -v
if php version is < 7.0 then install latest version of php.
Uninstall the old verion Xampp
Install latest version of Xampp to upgrade php.
I'm using LaravelStapler package to manage image in Laravel 5.1.
I installed LaravelStapler with the following steps:
Add "codesleeve/laravel-stapler": "^1.0" into composer.json file
Add 'Codesleeve\LaravelStapler\Providers\L5ServiceProvider' into providers array in config/app.php file
Run composer install
And faced the error:
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Codesleeve\LaravelStapler\Providers\L5ServiceProvider' not found
If i run composer install before add 'Codesleeve\LaravelStapler\Providers\L5ServiceProvider' into providers array in config/app.php file, no error occurs.
It's hard for me to deploy into productions when I need to comment out 'Codesleeve\LaravelStapler\Providers\L5ServiceProvider' before composer install and uncomment after in production.
Are there any solutions which I can install it without commenting out 'Codesleeve\LaravelStapler\Providers\L5ServiceProvider' ?
Thanks in advance !
Update:
Sorry, It's my mistake. My team mate ignored composer.lock in Repository. I reviewed his pull-request and didn't realize that. Everything works as normal.
I just want to ask a question. I just want to ask if there's a way to include ServiceProviders in Laravel manually? I looked in github page and I saw some laravel serviceprovider. How can I include those in my laravel file? I am new to laravel and I am studying this in our home without an Internet connection. I downloaded the HTMLServiceProvideer manually and I also tried the command:
composer require illuminate/html
Can the composer run without having an Internet Connection? If no how can I install a serviceprovider by using the master-files? Where should I place the files and what file should I need to update?
I believe this is possible but you need to manually do the work of the Composer.
So for instance lets assume want to manually install illuminate/html package.
You can follow these steps:
Add "illuminate/html": "5.*" to your composer.json although we are not using Composer for installing this package, its important we have this listed in composer.json should in case we run 'composer update' in the future our manually added package will not be deleted but rather updated.
"require":{
"laravel/framework": "5.0.*",
"illuminate/html": "5.*"
}
Manually download the package from Github and place the package inside
vendor directory which is located at the root of your laravel application
example in mylaravelapp/vendor
Add the package to mylaravelapp/vendor/composer/autoload_namespaces.php
return array(
.....
'Illuminate\\Html\\' => array($vendorDir . '/illuminate/html'),
);
Add the package to mylaravelapp/vendor/composer/autoload_namespaces.php
return array(
....
'Illuminate\\Html\\' => array($vendorDir . '/illuminate/html'),
);
Run composer dump-autoload to check for errors
Add Package service provider in config/app.php 'providers' => []
Run composer dump-autoload once more
Service Providers are added to your config/app.php
But you will need to have that package downloaded...
I've installed Httpful as described with Composer adding to composer.json the following:
{
"require": {
"nategood/httpful": "*"
}
}
I'm using Laravel 4 so i ran composer install
I've checked if the plugin is installed and is there, in fact under the vendor folder of laravel i can find it. But i keep getting the following error:
ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Httpful' not found'
I'm missing some steps?
Thank you in advance
The class related to this package name conflicts with Laravel's Response class, so this is how you use it in Laravel:
$url = "http://api.openweathermap.org/data/2.5/weather?lat=22.569719&lon=88.36972";
$response = \Httpful\Request::get($url)->send();
echo $response->body->name."<br>";
echo $response->body->weather[0]->description;
The class is not Httpful, but Response, so you have to add the correct Namespace so it doesn't get confused by Laravel's Response class.
EDIT:
In Laravel you can create aliases for classes. Edit your app/config/app.php and in the aliases array, add:
'aliases' => array(
....
'Httpful' => '\Httpful\Request',
),
And you'll be able to use it this way:
$response = Httpful::get($url)->send();
You may need to do composer update rather than composer install.
The difference being install will go by whatever is in your composer.lock file, while update will pick up any new dependencies added into your composer.json file, and then write those to your composer.lock file.
Note: install should generally be used in production to get the latest from your composer.lock file, while update is generally a command used in development to get your updated dependencies.
This also means you should add composer.lock to your git repository, even tho it's in your .gitignore file by default in a new Laravel project.