created serviceprovider then removed the file manually and am getting error - laravel

I created this provider:
php artisan make:provider ShortcodesServiceProvider
I then had to delete the file, but am now getting
FatalThrowableError in C:\xampp\htdocs\listagram\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php line 146:
Class 'App\Providers\ShortcodesServiceProvider' not found
How do I reset serviceproviders after manually deleting the provider file I created?

You should delete bootstrap/cache/services.php file manually and run composer dumpauto command to fix this.

Related

Remove package from laravel-6.2 existing project an error occurred

Remove pragmarx/tracker package from laravel project by the following composer command
composer remove pragmarx/tracker
It's remove successfully but the below error shown. Even though composer update the error not fix.
Illuminate\Contracts\Container\BindingResolutionException
Target class [PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker] does not exist.
How can I fix this error ? and which method to follow to completely remove any unused packages from laravel?
From the documentation on the repo:
Installing
Require the tracker package by executing the following command in your command line:
composer require pragmarx/tracker
Add the service provider to your app/config/app.php:
PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class,
Add the alias to the facade on your app/config/app.php:
'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade',
Publish tracker configuration:
Laravel 4
php artisan config:publish pragmarx/tracker
Laravel 5
php artisan vendor:publish --provider="PragmaRX\Tracker\Vendor\Laravel\ServiceProvider"
Enable the Middleware (Laravel 5)
Open the newly published config file found at app/config/tracker.php and enable use_middleware:
'use_middleware' => true,
Add the Middleware to Laravel Kernel (Laravel 5)
Open the file app/Http/Kernel.php and add the following to your web middlewares:
\PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
...
If you removed the package, make sure to
delete the config/tracker.php file
remove the line PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class from config/app.php
remove the line 'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade', from config/app.php
remove the line \PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class, from app/Http/Kernel.php

no php artisan commands are working after new migration

I am new to laravel .
Following tutorial videos on laracast,i made a new migration (cmd command) like following
php artisan make:migration delete_title_from_posts_table
which gave me the message
Created Migration: 2020_02_05_185721_delete_title_from_posts_table
after that no php artisian command is working in cmd.
Any command i run gives me the following error
In Container.php line 805:
Target class [db] does not exist.
In Container.php line 803:
Class db does not exist
what would be causing this?
my laravel app version=6.2 and php version=7.3.5 on Win10 64-bit.
similar questions i already viewed,not working for me
artisan-commands-not-working-after-composer-update
in-container-php-line-805-target-class-db-does-not-exist
Since it's a facade, add this to the top of the class to make it work:
use DB;
Or use full namespace:
$tables = \DB::table...
run these commands steps by step:
composer dump-autoload clean up all compiled files and their paths
composer update --no-scripts Skips execution of scripts defined in composer.json
composer update update your project's dependencies

How to rollback mistyped migration in Laravel?

I have created a migration using the command
php artisan make:migration create_members_table.php --create=members
So it created a class name CreateMembersTable.php including .. Now I want to rollback it and to correct the class name.
php artisan migrate:rollback --step=1
and I see this error as expected:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected '.', expecting '{'
OR
In order Laravel not to notice if I delete the file manually, how to do it?
Just delete the file and create a new one. Rollbacks are used for database not the migration files itself.
Or you can rename the file and the class name and if you get errors running the migration then run composer dump-autoload.

Laravel migrations messed up

I meesed up my Laravel migrations and I get PHP Fatal error: Cannot redeclare Class when running
php artisan migrate --path="workbench/fefe/feeds2go/src/migrations"
I have been deleting the migration file and dropping manually the table and recreated with php artisan migrate:make but still the same.
How can I fix migratons?
You need to check all of your migration class files and check for duplicate class names.
"Cannot redeclare class" happens when the class name appears at least
2 times.
The easiest way to do it is to run either composer install or composer.phar dump-autoload. It will generate warning information for you to identify which class is duplicated. Then, simply remove the class that declared twice.
Here is the error I got after I ran php artisan migrate
[Symfony\Component\Debug\Exception\FatalErrorException]
Cannot redeclare class CreateKidTimeslotTable
Therefore, I use composer.phar dump-autoload to identify the error.
Warning: Ambiguous class resolution, "CreateKidTimeslotTable" was found in both "laravel/database/migrations/2016_05_23_024341_create_kid_timeslot_table.php" and "laravel/database/migrations/2016_08_24_022635_create_kid_time_slot_table.php", the first will be used.
Remove the duplicated table that you don't need anymore.
You need to delete that migration file manually from the migration directory of your project and also, delete it's entry from the migration table in the database or you can run the php artisan migrate:refresh but it will drop your all table data so also add the your step with php artisan migrate:refresh --step=n
This is a late answer, but probably this would solve your issue.
Go to app/storage/migrations.
Delete the migration file that causes the error (You can also delete everything stored there).
Done.

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