Class '\App\User' not found after updating laravel 7 to 8.47 - laravel

I have tried everything I found regarding this issue... I am still getting that error
"Class '\App\User' not found" in
Illuminate\Auth\EloquentUserProvider::createModel
vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php:183.
The web project was initially developed in Laravel 7. So I uploaded both composer.json and composer.lock on the web server and upgraded to Laravel 8 with composer install.
I then sync the following folders from local to web :
app, public, resources, routes & vendor.
Finally I run the following commands :
php artisan cache:clear,
php artisan config:clear &
php artisan config:cache.
I get the error after login in on my web project. On the local project it works 100%, with all the table controllers in App/Models including App/Models/User and properly referenced in all the files using it.
I don't know what else I can do... and I need this project www.fairtradetourism.org running by the end of this day. Please help...

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

Laravel deploying 403 Access Forbideen

I'm trying to deploy my laravel 8 project in my hosting.
After I publich whole files of the projct, I got the 403 Access Forbidden.
My websites on the server work perfectly, but this project I don't know what's is the problem.
And I'm sure that the problem in the project files not in the server.
This is the website: [Sheeks] (http://manage-sheek.manarat-free.com/)
If all of your configurations at server is correct then it's because of cached data. Run commands:
php artisan config:cache
php artisan route:cache

This page isn’t working, Currently unable to handle this request. HTTP ERROR 500 on Laravel

Before Laravel, I have been using the MVC Web Framework and success to host in cPanel server.
Now, I decide to upgrade my Framework. So I find Laravel because it also included MVC patterns and easy to learn for me. Seeing some tutorials, I decided to host a simple project of Laravel on a subdomain of my main domain sites.
What I did:
On server:
I create a subdomain and set the document root to /public_html/subdomain.maindomain.com/public.
Inside the public_html folder, I created a folder and renamed as just like to subdomain name.
On My Computer
composer global require laravel/installer
laravel new website
php artisan serve
Now, I get the Laravel homepage on browser link http://127.0.0.1:8000.
Then, I added bootstrap.
composer require laravel/ui
php artisan ui bootstrap --auth
npm install && npm run dev
Then, I see the login and register link on the Laravel homepage.
Now, seeing https://laravel.com/docs/8.x/deployment documentation of Laravel:
composer install --optimize-autoloader --no-dev
php artisan config:cache
php artisan route:cache
php artisan view:cache
Now, I uploaded the zip file (all files inside the website folder) and extracted it to server document root /public_html/subdomain_name/. In the subdomain_name folder, I have all the files that were in my website folder on my computer.
I don't change anything on the index.php file of the public folder, remain on default condition.
require __DIR__.'/../vendor/autoload.php;
$app = require_once __DIR__.'/../bootstrap/app.php';
Then, I check my URL but I faced This page isn’t working, subdomain.domain.com is currently unable to handle this request. HTTP ERROR 500
First of all upload the laravel to your domain root folder and not public_html and extract, then move the content of the public folder of your laravel to /public_html/subdomain.maindomain.com/public then edit the content of the index.php require __DIR__.'/../vendor/autoload.php'; equire_once __DIR__.'/../bootstrap/app.php'; to this require __DIR__.'/../../../laravelpackagename/vendor/autoload.php' and $app = require_once __DIR__.'/../../../laravelpackagename/bootstrap/app.php';
Not tested but I believe this should work
How did I solve this error:
I re-create the Laravel new project just like the above command and put that file to my server path to /public_html/laravel/. Therefore, I didn't change anything on the index.php file on the public folder, remain to the default condition. By doing this still error remains same (HTTP ERROR 500).
Then, I look at the error_log file at /public_html/laravel/public/, and see an error Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in public_html\laravel\vendor\ramsey\uuid\src\functions.php line on 34.
In cPanel MultiPHP Managers, I select my sites and set the PHP Version to the same version it has before [PHP 7.3 (ea-php73)]. Then, BOOM!! It worked. I see the homepage of my laravel project in the URL.
In brief, selecting the same PHP Version in cPanel MultiPHP Managers, help me to solve this error.

Laravel Artisan make command issue

I am trying to make a middleware using artisan php artisan make:middleware AuthorizedUserOnly but I get ErrorException like below.
file_get_contents(/mysite.com/www/local/composer.json) Failed to open stream no such file or directory.
This is my document root.
-local
-Laravel application folders
-artisan
-index.php
-composer.json
.htaccess
I changed my directory structure to work with shared hosting. And It was working fine.
KEY NOTES
Other artisan commands work. Like I tried php artisan route:list & php artisan config:cache & php artisan tinker.
This directory structure works fine.But as the error says that it is trying to find composer.json in local directory while it is on document root.
php artisan make:model command spits the same Exception
What could be the possible issue and solution ?
Solution : I moved my composer.json file to local directory and it worked fine. So new directory structure is
-local
-Laravel Application Folders
-composer.json
-artisan
-index.php
.htaccess
HOW ?
I am not sure about this yet. But this is the possible reason. php artisan make command create some files. So to included these created files into system execute composer dump-autoload. So to run composer it looks for in the same directory where artisan lives which is local directory in my case.
IMPORTANT
I changed laravel default directory structure to successfully run my applicaiton on SHARED HOSTING which laravel DOESNOT RECOMMEND.
We should follow the recommendations made by laravel to avoid any similiar issue. Specially never to mess with default directory structure at least.

moving Laravel project between computers

I have been working on a laravel5 project on a computer , but now I want to continue on an other, but don't know how :(
I'm using wampserver and the project is in the "www" folder, this is the error I'm getting when trying to open the project: " Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request"
Your error message is very vague, so it is hard to pinpoint the cause. I assume you just copy pasted all of the project files
Try these steps:
Make sure you copy all of the project files including the hidden ones(.env).
Prepare your destination computer as in http://laravel.com/docs/
Check you have all the necessary PHP extensions available in php.ini as in above link requirements. Also, watch your PHP version!
Install composer https://getcomposer.org/doc/00-intro.md
When copied, go to your destination folder and run composer install.
Run php artisan key:generate from the command line.
Run php artisan cache:clear from command line
http://php.net/manual/en/install.windows.commandline.php
Make sure your webserver is serving pages from project/public folder.
If laravel is failing, check the log file to see the cause
your_project/storage/logs/laravel.log
Copy the project folder and navigate terminal/cmd
just run following commands.
Create database and place the same name at .env file in laravel project folder
1. composer install
2. php artisan key:generate
3. php artisan cache:clear
4. php artisan migrate
UPDATE: If you're getting
Whoops, looks like something went wrong
in app/config/app.php, set debugging as true with:
'debug' => env('APP_DEBUG', true)'
If you're getting the error
No supported encrypter found. The cipher and/or key length are invalid
for some people it worked to do cp .env.example .env before (2).
You would also have to create new storage link, because Laravel uses absolute path inside it.
php artisan storage:link
https://stackoverflow.com/a/32722141/3982831 Please follow this to resolve your problems. All people forget about permissions on folders.
After you have done as Ademord answer, you might need to use refresh to your WAMP, XAMP or any other development stack you are using. I had the same issue plus changes were not reflecting in the front end. For example new routes in the web.php were not updating.

Resources