PHP Fatal error: Class 'Vinkla\Hashids\HashidsServiceProvider' not found - php

I was developing on my dev machine using Homestead. I committed both my composer.lock and composer.json. During this branch, I added Hashid and LaravelDebugBar to composer for development purposes. Everything worked fine on the development machine.
Once I pulled from master to my production machine, and ran composer update, and I get the following error:
When I type in php artisan migrate or composer update, I get the following error:
PHP Fatal error: Class 'Vinkla\Hashids\HashidsServiceProvider' not found in /var/www/schedulizer/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Vinkla\Hashids\HashidsServiceProvider' not found
I tried composer clear-compiled, composer dump-autoload tried manually requiring the Hashid package, and removing the offending lines in config/app.php and running composer update
I checked the service provider, and it is in my config/app.php..

Instead of running composer update, run composer install on the production machine instead; this will bypass the pre-update hooks that Laravel runs.
Source
If they were dev requirements, then you can conditionally add them to your service providers list by adding them to your AppServiceProvider like such:
// AppServiceProvider.php
public function register()
{
/* ... */
if ($this->app->environment('production')) {
// $this->app->register('');
} else {
$this->app->register('Vinkla\Hashids\HashidsServiceProvider');
}
}
Source

First of all, check if Vinkla\Hashids\HashidsServiceProvider exists. Also, double check all letter (it's always better to copy-paste namespace from documentation). Then try to run this command:
composer dumpauto
If it will not help, run this command:
composer dumpauto -o

I tried php artisan config:clear then I ran composer update and composer install but I got the same error message.
in my case, the problem was in bootstrap/cache/config.php
So I deleted the file manually and mission accomplished.

Related

Why new installed laravel not work on shared hosting?

Now I have installed the Laravel framework using composer command "composer create-project --prefer-dist laravel/laravel myappname" on a local server and everything works fine. Then with the same composer command installed on the shared hosting but nothing works. When I visit to index page return error:
Failed to load resource: the server responded with a status of 500 ()
When I run command php artisan return error on cosole:
PHP Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found in /home/c/cn89872/website.com/public_html/bot/ii/bootstrap/app.php:14
How can be solved my problem?
First of all run this command:composer dump-autoload This command will clean up all compiled files and their paths.
After composer update --no-scripts This command will Skips execution of scripts defined in composer.json
Finally, update your project's dependencies: composer update

How can I resolve installation error with Laravel LaraAdmin?

I'm trying to setup a fresh install of LaraAdmin
http://laraadmin.com
I've been following these instructions:
http://laraadmin.com/docs/1.0/installation#install
I receive an error when I get to the step of running
php artisan la:install
The Error received is:
[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'Dwij\Laraadmin\LAProvider' not found
I tried installing 3 times, twice with a local composer installation and once with a global composer installation - both resulting in the same error.
I've also confirmed that Dwij\Laraadmin\LAProvider::class is included in the providers section of config/app.php
When I change Dwij\Laraadmin\LAProvider::class to Dwij\Laraadmin\LAProviderASDF::class in config/app.php - the error becomes:
[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'Dwij\Laraadmin\LAProviderASDF' not found
So it's clear that the added line of code in config/app.php triggers this error.
How can I resolve the class not found error?
You need to import laraAdmin classes first via composer in the terminal:
composer require "dwij/laraadmin:1.0.40"
After that, you'll be fine running php artisan la:install
Paste this line bottom of the providers in config/app.php
Dwij\Laraadmin\LAProvider::class

Laravel 5 composer wont update class not found

Whenever I do composer update or artisan cache:clear and I get the following error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Fatal error: Class 'Aws\Laravel\AwsServiceProvider' not found
My app.php config file doesn't contain the AWS in the providers and or aliases. I've tried adding 'Aws\Laravel\AwsServiceProvider::class,' under providers and 'AWS => Aws\Laravel\AwsFacade::class,' under aliases but still the same issue. I think something is caching weird and doesn't recognize the updates I'm doing on app.php config file.
delete the files (not the directory) in bootstrap/cache
run composer dump-autoload
remove config/aws.php if it exists
run composer install
just do a : composer dump-autoload
and after that try to run you command like normal: composer update

Fatal error: Class 'Illuminate\Foundation\Application' not found

I am getting following error when I open my site which is made using laravel 5
Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\cms\bootstrap\app.php on line 14
I have tried removing vendor folder and composer.lock file and running composer install it's not working I tried running PHP artisan optimize but it shows error
Fatal error: Class'Illuminate\Foundation\Application' not found
Is there any way to solve this problem?
Edited:
This problem aroused as soon as I used the php artisan make:model Page command which did create the model but then the above error gets displayed when I access the site
Also If use the Laravel's Local Development Server no such problem arises only if I use wamp server
In my situation, I didn't have the full vendor dependencies in place (composer file was messed up during original install) - so running any artisan commands caused a failure.
I was able to use the --no-scripts flag to prevent artisan from executing before it was included. Once my dependencies were in place, everything worked as expected.
composer update --no-scripts
Just in case I trip over this error in 2 weeks again...
My case: Checkout an existing project via git and pull in all dependencies via composer. Came down to the same error listed within the title of this post.
Solution:
composer dump-autoload
composer install --no-scripts
make sure everything works now as expected (no errors!)
composer update
Something is clearly corrupt in your Laravel setup and it is very hard to track without more info about your environment. Usually these 2 commands help you resolve such issues
php artisan clear-compiled
composer dump-autoload
If nothing else helps then I recommend you to install fresh Laravel 5 app and copy your application logic over, it should take around 15 min or so.
Easy as this, that worked for my project
Delete /vendor folder
and execute composer install
then run project php artisan serve
In my case composer was not installed in that directory. So I run
composer install
then error resolved.
or you can try
composer update --no-scripts
cd bootstrap/cache/->rm -rf *.php
composer dump-autoload
I just fixed this problem (Different Case with same error),
The answer above I tried may not work because My case were different but produced the same error.
I think my vendor libraries were jumbled,
I get this error by:
1. Pull from remote git, master branch is codeigniter then I do composer update on master branch, I wanted to work on laravel branch then I checkout and do composer update so I get the error,
Fatal error: Class 'Illuminate\Foundation\Application' not found in
C:\cms\bootstrap\app.php on line 14
Solution:
I delete the project on local and do a clone again, after that I checkout to my laravel file work's branch and do composer update then it is fixed.
I had accidentally commented out:
require __DIR__.'/../bootstrap/autoload.php';
in
/public/index.php
When pasting in some debugging statements.
For latest laravel version also check your version because I was also
facing this error but after update latest php version, I got rid from
this error.
run composer require laravel/framework after composer install then php artisan key:generate its work for me in kali linux
I can't imagine that anyone else reading this is a stupid as I was but just in case...
I had accidentally removed "laravel/framework": "^5.6" from my composer.json when resolving merge conflicts.
please test below solution:
first open command prompt cmd ==> window+r and go to the location where laravel installed.
try composer require laravel/laravel
i was having same problem with this error.
It turn out my Kenel.php is having a wrong syntax when i try to comply with wrong php8 syntax
The line should be
protected $commands = [
//
];
instead of
protected array $commands = [
//
];
#kalhan-toress 's comment is what ACTUALLY WORKED FOR ME
remove /bootstrap/start.php,composer.lock, and the vendor and run composer install
In my case, the error was caused on initial deployment because I didn't have a .env file in that directory (because those don't belong on Github where the files were transferred from).
check your .env file i think you miss something. Maybe like this
if yes then need to add manually and composer update or install composer

Laravel error in /bootstrap/start.php: \Illuminate\Foundation\Application not found

So, I installed Laravel on a dev server (php5.5.3, standard installation, mcrypt installed), and I get the following error message:
Fatal error: Class 'Illuminate\Foundation\Application' not found in /[path_to_laravel_app]/bootstrap/start.php on line 14
Quite odd, and I haven't seen a solution to this file, although I've seen plenty of similar errors. Any advice welcome. Thanks!
/bootstrap/start.php is created after composer install by running Laravel's php artisan optimize. I've had a lot of issues on this during upgrades of Laravel, but removing /bootstrap/start.php, composer.lock, and the vendor directory and re-running composer install should fix this issue.
Run this command:
composer update --no-scripts
In my case I have added another required package(Guzzle) in the compser.json file separately(in the last line but it should be after the laravel package line) and updated the compsoser and came across this issue.
I have checked and my vendor/laravel folder has gone. That was preventing me to run any artisian command.
So "--no-scripts" worked for me as it prevents any scripts to be included before executing artisan.
You can use another method in case you are having issues.
Install another raw laravel and copy all the files from the vendor
file to your old repostory.
Change permission of storage and bootstrap folder to 775 or 777.
Delete everything in the session and view folder of storage/framework
Correct the composer.json. This might happen after you have added a new package configuration by dublicating the require tag.
Do not create yet another
require: {
..
}
use the previous defined one.
Then follow the accepted answer to re-install the packages.
Just Run the command
composer install --no-scripts
Or,
composer update --no-scripts
Double check your composer.json file. If you have error on "require": section this error will occur.
Just restore a previous version of composer.json file and run composer update.

Categories