my error : Class 'Maatwebsite\Excel\Excel' not found - laravel

this errormy composer.json:
...
"maatwebsite/excel": "^3.1",
...
I can run my project on localhost but when I upload on server I got this error message:
Class 'Maatwebsite\Excel\Excel' not found
my laravel version:
Laravel Framework 8.80.0

Please make sure that you imported class in config/app.php
If not then please add below line in prividers array in config/app.php file.
Maatwebsite\Excel\ExcelServiceProvider::class
then publish vendor by
php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config
Then after
composer dump-autoload

Related

Laravel Autoclosing after clicking one request

I have a problem when declaring autoload in laravel,
i have been using laravel 8 and php 7.4.3 this is the problem
After i get another request, the laravel runner always closing and give me this error
To solve this error, i've always do the
php artisan key:generate
or do another thing like restarting the laravel after dump autoload
composer dump-autoload
php artisan serve
But the problem just solve for one time, and it will be error again until i dump the composer again
How can i solve this?
In your composer.json file you should have the following line
"autoload": {
"psr-4": {
"App\\": "app/"
}
},
And in you artisan file you should have the following
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
The composer.json code should autoload any content coming from the App directory, while the require /vendor/autoloader will load vendor content into your project. Also you must have app.php inside of the bootstrap directory to allow the app to use the Kernal corrently. Hope this helps!

Laravel ide-helper installed fine but doesn't generate

BarryVdh's ide-helper has been sucessfully installed to my Laravel project as the composer.json desribes:
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
...
},
"require-dev": {
...
"barryvdh/laravel-ide-helper": "^2.1",
"doctrine/dbal": "^2.9"
},
Added to providers in app/config as:
'providers' => [
...
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
],
I assume it partially works as the command php artisan ide-helper:meta generates .phpstorm.meta.php in the root folder, but the php artisan ide-helper:generate command fails with the following simple error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected end of file
If I try to generate model info with the command php artisan ide-helper:models, asks for overwrite models or to write to _ide_helper_models.php instead, 'no' chosen, it fails and throws the same error above. However, if I add a model to the command (eg. php artisan ide-helper:models Order ), after choosing 'no' for overwrite the ide-helper generates the _ide_helper_models.php file without any relevant content, just the default comment block.
What to check in this case?
(phpStorm IDE, win10, Laravel 5.1, Xampp, PHP7)

Getting messages feature in Debugbar to work in Laravel

I've installed Debugbar for Laravel as described in the steps on the website https://laravel-news.com/laravel-debugbar; and tried to make use of the Messages feature by placing the following below in my code.
Debugbar::info($object);
Debugbar::error('Error!');
Debugbar::warning('Watch out…');
Debugbar::addMessage('Another message', 'mylabel');
But when I run my website, I get the error message from Laravel saying:
1/1
FatalErrorException in HistoryController.php line 11:
Class 'App\Http\Controllers\Debugbar' not found
I have to go like /Debugbar::info(...) or put use Debugbar at the top of my code to not get the error message. Why can't I use it straight like Debugbar::info(...)?
To be able to reference the facade without prefixing it with \ you should add
use Barryvdh\Debugbar;
to the top of your controller.
after adding setting code in /config/app.php
you can use it as a facade
app('debugbar')->info('info message');
or
debugbar()->info('message');
no need use
I think you should try this :
first you add below code in config/app.php
in provider section
'Barryvdh\Debugbar\ServiceProvider',
in aliases section
'Debugbar' => 'Barryvdh\Debugbar\Facade',
after you should clear the cache like:
php artisan config:cache
php artisan cache:clear
php artisan config:clear
Hope this work for you !
Firstly, Go to the terminal and install by typing:-
composer require barryvdh/laravel-debugbar
In second step, Check your laravel verision:-
php artisan --version
In third if your laravel version is greater than 5(Laravel 5.x)
add the ServiceProvider to the providers array in config/app.php
Barryvdh\Debugbar\ServiceProvider::class,
add this to your facades in app.php:
'Debugbar' => Barryvdh\Debugbar\Facade::class,
Finally, published vendor configuration by command:-
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
After vendor published clear cache,route,view by command
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan dump-autoload -o

Installing Riari/Laravel forum with composer - error - class not found

I am trying to install Riari forum for Laravel and I follow strictly the steps from http://teamteatime.net/docs/laravel-forum/3.x/installation.md
When I type php artisan vendor:publish in the console, it gives me this error:
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Riari\Forum\ForumServiceProvider' not found
How can I fix it?
You need to put this (Riari\Forum\ForumServiceProvider) in Config/app.php inside service provider in the same format where already some providers are added

laravel PackageServiceProvider not found; moving from workbench to vendor

This is basically a problem of moving a laravel package from workbench to vendor, but the solutions in other threads have not worked in this case:
I have a package iateadonut/signup.
I created a fresh laravel installation (laravel_test), and, just for testing sake, I put iateadonut/signup in laravel_test/workbench/.
I put Iateadonut\Signup\SignupServiceProvider, in the 'providers' array in app.php.
I then run:
/laravel_test> php artisan dump-autoload
and get:
Generating optimized class loader
Running for workbench [iateadonut/signup]...
My package is successfully installed.
On a fresh installation of laravel (laravel_test), I then put iateadonut/signup in larael_test/vendor.
I put Iateadonut\Signup\SignupServiceProvider, in the 'providers' array in app.php.
I then run:
/laravel_test> php artisan dump-autoload
and get:
PHP Fatal error: Class 'Iateadonut\Signup\SignupServiceProvider' not found in /var/www/html/laravel_test/bootstrap/compiled.php on line 4214
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'Iateadonut\Signup\SignupServiceProvider' not found","file":"/var/www/html/laravel_test/bootstrap/compiled.php","line":4214}}
Any idea what could be wrong?
Here is a more google friendly version in case someone else is looking for this:
PHP Fatal error: Class 'Vendor\Package\PackageServiceProvider' not found in /var/www/html/laravel/bootstrap/compiled.php on line 4214
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'Vender\Package\PackageServiceProvider' not found","file":"/var/www/html/laravel/bootstrap/compiled.php","line":4214}}
Try to remove the the bootstrap/compiled.php file and try your composer dumpautoload again

Resources