I just cloned a Laravel/Vue.js project from Bitbucket (for a company I'm working with), trying to set it up on my computer. This isn't my first time doing this, as I've previously cloned and worked on many projects. But for this one, I can't figure out the problem. I've run Composer, copied the .env file, generated a new key, and run all migrations. I've always used this process when cloning laravel projects - cloning laravel project from github.
When I try to load any of the pages (login, register, home, any page at all), it shows a 404-page not found.
To debug the problem, I tried to dismember it from the VueJs component by removing the app.js script from the home page so that it shows only the HTML document in the home.blade.php file, but it still didn't work - so I'm sure the problem is not a VueJs problem.
I've checked the routes in the web.php file to make sure it's hitting the right controllers, and it is. However, I noticed that although it hits the right controller, it doesn't read any of the functions inside it. I know this because it doesn't even throw an error when I change the function names. I'm attaching a list of the first few routes and the first few lines of the HomeController.php page.
Web.php
use Illuminate\Http\Request;
use Illuminate\Log\Logger;
use Illuminate\Support\Facades\Hash;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'HomeController@show');
HomeController.php
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return Response
*/
public function show()
{
//sensitive information removed
return view('home', array(
'user' => $user
));
}
}
CodePudding user response:
I think your public folder doesn't have the .htaccess
if you didn't find the .htaccess file, you can get your copy from here
https://github.com/laravel/laravel/blob/9.x/public/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (. )/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
also you need to make sure that your web server (apache or nginx ..etc) enabled the mod_rewrite otherwise the URLs will not working
I hope it's helpful
CodePudding user response:
Route::get('/', [HomeController::class,'show']);