I've just started learning the Laravel framework and I'm having an issue with routing.
The only route that's working is the default home route that's attached to Laravel out of the box.
I'm using WAMP on Windows and it uses PHP 5.4.3, and Apache 2.2.22, and I also have mod_rewrite enabled, and have removed the 'index.php' from the application.php config file to leave an empty string.
I've created a new controller called User:
class User_Controller extends Base_Controller {
public $restful = true;
public function get_index()
{
return View::make('user.index');
}
}
I've created a view file in application/views/user/ called index.php with some basic HTML code, and in routes.php I've added the following:
Route::get('/', function () {
return View::make('home.index');
});
Route::get('user', function () {
return View::make('user.index');
});
The first route works fine when visiting the root (http://localhost/mysite/public
) in my web browser, but when I try to go to my second route with http://localhost/mysite/public/user
I get a 404 Not Found error. Why would this be happening?
the simple Commands with automatic loads the dependencies
and still getting that your some important files are missing so go here to see whole procedure
https://codingexpertise.blogspot.com/2018/11/laravel-new.html
If you're using Vagrant though Homestead, it's possible there was an error mounting the shared folder. It looks like Vagrant takes your files from that folder and swaps out the files that are actually on the host machine on boot, so if there was an error, you're essentially trying to access your Laravel installation from when you first made it (which is why you're only getting "home"- that was generated during installation).
You can easily check this by sshing into your vm and checking the routes/web.php file to see if it's actually your file. If it isn't, exit out and
vagrant halt
,vagrant up
, and look for errors on boot.You could try to move
root/public/.htaccess
toroot/.htaccess
and it should workDon't forget the "
RewriteBase
" in yourpublic/.htaccess
:For example :
change above to
You have to use '/'(home/default) at the end in your routes