Laravel - PHP Fatal error: Class 'CreateMatchesTable' not found in migrate:refresh - laravel

Recently I cleaned up my tables locally, and this resulted in me deleting 'Match' table. I am now receiving errors on the production server because of this.
Locally, I ran php artisan migrate:reset, deleted the 'CreateMatchesTable' file and then php artisan migrate:refresh --seed. This worked locally and I then pushed my most recent build to the server.
Now, whenever I run php artisan migrate:refresh --seed on the production server, I'm presented with the following error:
PHP Fatal error: Class 'CreateMatchesTable' not found in
/home/forge/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php
on line 301
PHP Stack trace:
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException",
"message":"Class 'CreateMatchesTable' not found","file":"\/home\/forge
\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Migrations\/
Migrator.php","line":301}}
I have read about other people experiencing this and I've tried composer dump-autoload- but the problem still persists.
Also, php artisan dump-autoload unfortunately presents me with this error:
Generating optimized class loader
Compiling common classes
[ErrorException]
Array to string conversion
dump-autoload
I've deleted the site and rolled back migrations on Laravel Forge, and still, when it pulls the latest build into Forge this error occurs!

You should delete the row from your migrations table in your database.

The solution for that is
composer dump-autoload

Related

Please how can I undo ''php artisan livewire:make product-ratings''

After running the command I realized that I don't want to use it again so I deleted the two components it created which are
CLASS: app/Http/Livewire/ProductRatings.php
VIEW: resources/views/livewire/product-ratings.blade.php
Now when I try to access my product in the frontend I get this error
include(C:\xampp\htdocs\keyi\vendor\composer/../../app/Http/Livewire/ProductRatings.php): Failed to open stream: No such file or directory
2 possibilities
You have actually deleted it but it still thinks its there so do php artisan view:clear
or
It seems like you are trying to access a Livewire component that has been deleted, but your application is still trying to include it. This is causing the error message "include(C:\xampp\htdocs\keyi\vendor\composer/../../app/Http/Livewire/ProductRatings.php): Failed to open stream: No such file or directory".
To resolve this issue, you will need to remove any references to the deleted Livewire component from your code. This could include removing references to it in your routes, controllers, views, or other parts of your application.
Once you have removed all references to the deleted component, you should be able to access your product in the frontend without encountering the error message. If you continue to have trouble, you may want to check your logs or run your application in debug mode to get more information about the problem.
Did you try livewire:delete
php artisan livewire:delete product-ratings
and run
php artisan cache:clear
php artisan config:clear
composer dump-autoload # if needed
saw this command in the web livewire:remove.(Not sure if exist)
php artisan livewire:remove product-ratings

Migration Table Creation Error when using Laravel Sail. Information_schema.tables missing

My colleague has created a docker-composer.yml file and has shared that image with me.
When I run the container and attach this image, I am unable to create migratation tables through the command; "./vendor/bin/sail artisan migrate". I am using mySQL DB. I've tried running the following commands: (they worked for my other colleague when he got the error in image 1 below).
./vendor/bin/sail --rmi all -v
./vendor/bin/sail up -d
./vendor/bin/sail artisan config:clear
./vendor/bin/sail artisan cache:clear
./vendor/bin/sail artisan migrate
The following is the error message I get once I execute ./vendor/bin/sail artisan migrate.
Also, when I try "sail up -d", it shows me laravel.test error. However, it still completes the build. (Is the error in image 1 related to the error in the image below?)
Would appreciate any kind of help, thanks.
.env file changed from DB_HOST=localhost to DB_HOST=mysql. The issue was in the .env file parameters. Everything works fine now.

I uploaded a laravel 8 on my subdomain and i received error

i uploaded my laravel 8 project to my subdomain and i received this error
file_put_contents(E:\Projects\API\api-worforce\storage\framework/sessions/UkfntojT5Qzf99w9TR6Jvxs6iOBKlJ3TvLB6clTF): failed to open stream: No such file or directory
its still using local directory
Some of Laravel files are so-called cached. Therefore, the cache must be removed to fix this error as well.
How to fix the problem(two methods):
Method 1: Just go to the following path of your project in Laravel host and rename the config.php file to config_old.php or delete this file completely:
bootstrap / cache
Method 2: If the first method is not effective in solving the problem, run the following command this time:
php artisan config:clear
php artisan cache:clear
php artisan congif:cache

How to run seeder under Users module

I need to run Laravel 6 application
and after running migrations I see that many tables are empty, including users.
In modules subdirectory I found files
/Modules/Users/Database/migrations/create_users_table.php
/Modules/Users/Database/seeders/UsersSeeder.php
Last file has default users
It was strange that running command
php artisan module:list
I see list of modules, but not Users module, as I expected
So I got error running in the root of my app:
php artisan module:seed Users
RuntimeException : Module [Users] does not exists.
I tried to run only this seeder, but again with error :
$ php artisan db:seed --class=/Modules/Users/Database/seeders/UsersSeeder
Illuminate\Contracts\Container\BindingResolutionException : Target class [/Modules/Users/Database/seeders/UsersSeeder] does not exist.
How can I run seeder under Users module(which I do not see in output of php artisan module:list)
?
Thanks!
If you use artisan command to make seeder
php artisan make:seeder UsersSeeder
You get the file in
database/seeds/UsersSeeder
Then you can call
php artisan db:seed --class=UsersSeeder
Instead of
php artisan db:seed --class=/Modules/Users/Database/seeders/UsersSeeder
Do not forget to run
composer dump-autoload
after first command

Laravel migration undefined index

I am using Laravel 5.3.I deleted one of my migration files name 'feature' and everything related to it very carefully like its id from other tables etc.then i manually deleted the table from database.But now while i'm running the command "php artisan migrate:refresh".It's showing error exception with 'undefined index:***_create_features_table'.And when I'm running just 'php artisan migrate'.it shows that it was successful and all the tables successfully appear in the database.but then when i run migrate:refresh all the table disappears.what should i do to completely delete the migration file?
Try this.
First Manually delete the migration file under app/database/migrations/my_migration_file_name.php
Reset the composer autoload files: composer dump-autoload
Modify your database: Remove the last entry from the migrations table
Here is what I did.I cleared all the data from the database including all tables and then ran 'php artisan migrate'..that is how i made it work..But i am looking for a better solution which will not need to delete everything from the database.
Try check that you have the correct migrations first
php artisan migrate:status
Then you can try something like
php artisan migrate:refresh --step=1
And check again the status.
If you have Undefined index error and your migration was made with --path option, then add to your ModuleServiceProvier boot() method:
$this->loadMigrationsFrom(base_path('database/migrations/directory-name'));
in the migration just add $table->index(['column Name 1',''column Name 1']);
With my case, I forgot to do the Laravel migrate before running Infyomlabs to create scaffold!
So one of the reasons for "Undefined index" is that the table is not there yet.

Resources