I want to put a pie chart on my laravel project and install a library consoleTvs. But I decided to remove it from composer since I use a jquery instead.
When i try to run my project I use to have a error message
Class 'ConsoleTVs\Charts\ChartsServiceProvider' not found.
Without seeing ANY code it's very hard to help you.
I try to guess: you are not importing ChartsServiceProvider class so, still guessing, you can put at the start of your file
use App\Providers\ChartsServiceProvider;
So now you want to remove a library from composer.
i hope you remove it correctly. still you can follow below how to remove.
so remove that library code into your composer.json. and hit composer update.
so Hope you remove it correctly, so after removal you facing error of provider.
I guess on the time of installing you manually add a provider into your app.php file inside config folder.
So if, Am right, just go to your app.php file inside config folder and remove that provider as well as its alias too if you give it before.
Related
Just upgraded from Laravel 6 to 7, and had the error response above when submitting a contact form. I eventually found a solution that seems to work and I am submitting here to help out the next guy.
In the terminal run:
composer require illuminate/mail
Add the following to the top of the controller file (app/Http/Controllers/Main.php in my case):
use \Illuminate\Support\Facades\Mail;
Add this to bootstrap/app.php:
$app->register(Illuminate\Mail\MailServiceProvider::class);
Save and test, and it worked localhost.
If the above does not work for you, there are some other possible issues and solutions available at this link, where I must give credit to vipindasks.
https://laracasts.com/discuss/channels/lumen/lumen-52-mail-not-working
Since I am suppose to ask a question:
Do you see any problems with this solution even though the site and mailer is working now?
You are simply missing a backslash. This tells the autoloader that the file you are looking for is not in the namespace your controller resides in :
$app->register(\Illuminate\Mail\MailServiceProvider::class);
Run composer update hope this will help you
Something strange happened to me today : a collegue changed something in config/app.php , so that a different class is used as a service provider instead of the original one.
The code for this new class is in a package that was added to composer.json.
I updated from SVN and got both new files, but then composer update didn't work, because this somehow uses the config/app.php , which was broken, because it didn't know the class, which of course would only be in vendor AFTER composer update !
So my question is : why would composer update need anything that is in config/app.php ? And how to prevent something like this in the future?
Go to your config/app.php file and comment out the provider which was added by your colleague. Run composer update and then uncomment it, maybe php artisan optimize too and then you should be good to go.
EDIT: When a new package has been added by someone else, you need to install it. You only need to run composer update when you want to update all of your packages to their latest versions, or the framework.
I am trying to install Laravel Spark into an existing app. I have not changed the default namespace of "App".
I get the following error on install:
Class 'Laravel\Spark\Providers\SparkServiceProvider' not found
How can get around this error?
It means you didnt attach a class for laravel to detect it ..
Go to App/Config..open app.php..
scroll down.. youll see a providers list.. add a new line to it like
Laravel\Spark\Providers\SparkServiceProvider::class,
Save and Try again :)
I'm working on migrating an existing Laravel 3 application over to Laravel 4.1, and routes are kicking my butt right now. Here is the problem I'm having- in the old application we made frequent use of Route::controller() in the routes file. When I bring those entries over to the new application they seem to work, but they cause composer to get nasty.
For example I have this route:
Route::controller('templates', 'AdminTemplatesController');
Which is working as a route. But when I run composer update I get this error:
{"error":{"type":"ReflectionException","message":"Class AdminTemplatesController does not exist","file":"\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/ControllerInspector.php","line":28}}
I've tried stripping down and using Artisan to create an entirely new controller- same test, same fail.
Any ideas what I'm doing wrong?
Looks like you have to do it in steps:
1) Disable all of your routes
2) Execute composer update and make the process pass, you don't need your routes to do that
3) Reenable the controller route and fix the issue Laravel is having by not finding it, which could be:
Controllers folder not being loaded in composer.json
Namespace not being loaded in composer.json
In all of those cases, you have to be sure that you have your controllers in any of the files of the folder:
vendor/composer
For example, if you have the controllers folder in the autoload->classmap of composer.json, the file will be:
vendor/composer/autoload_classmap.php
Remember that every time you change composer.json, you have to
composer dumpautoload
So it recreates those files.
EDIT:
About your comment, I had similar problem once when my file was printed in command line, was happening because I had:
<?
instead of
<?php
This makes difference for Laravel.
In Laravel 4 you use "Route::resource()". So your example would be Route::resource('templates', 'AdminTemplatesController');
http://laravel.com/docs/controllers#resource-controllers
So a while back I decided to redo one of my models in Laravel completely, but I wanted to hold on to the original copy of the file just in case. So I renamed it to something like MyModel (OLD).php and left it there in the models folder next to the new model.
Now that I understand Laravel a bit better, I realize that wasn't a great idea, but in any case everything seemed to work for months. Then today, I made a minor update (modifying a database query) to one of the functions in my new model and suddenly Laravel is trying to load the old copy of my model. I finally moved the old copy out of the models folder and into a backup folder completely outside of my laravel application, but now Laravel throws the error:
include(pathToMyModels/MyModel (OLD).php): failed to open stream: No such file or directory
referring to this section of ClassLoader.php
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}
I tried undoing the modification to the model, changing the route and controller function name, clearing laravel's cache, clearing the browser cache, using different browsers, but nothing seems to work except to manually include the model's php file before calling the class it contains. What can I do to get Laravel to automatically recognize my model like it does all the others I have?
Try to clear composer cache and then run composer dump-autoload.
composer clear-cache
composer dump-autoload
if you don't want to run commands then try this one, i think it's solve your problem.
goto your laravel_project_folder\vendor\composer
now open the file autoload_classmap.php and autoload_static.php in your text editor
and find your old/backup file name line
and rename with actual filename and correct their path.
now run your project again and check for the error occurance, i think your problem is solved.
i just knew that my laravel using old controller after 1 hour of debuging. what time waste
i tried accepted answer but still persist
i delete the controller and recreate, now works
copy all the code
delete the controller
make http request to that controller (404)
create file same name
paste in