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
the simple Commands with automatic loads the dependencies
composer dump-autoload
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
The Main problem of route not working is there is mod_rewrite.so module in macos, linux not enabled in httpd.conf file of apache configuration, so can .htaccess to work. i have solved this by uncomment the line :
# LoadModule rewrite_module libexec/apache2/mod_rewrite.so
Remove the #
from above line of httpdf.conf
. Then it will works.
enjoy!
I think you have deleted default .htaccess file inside the laravel public folder. upload the file it should fix your problem.
Using WAMP click on wamp icon ->apache->apache modules->scroll and check rewrite_module Restart a LoadModule rewrite_module
Note, the server application restarts automatically for you once you enable "rewrite_module"
Routes
Use them to define specific routes that aren't managed by controllers.
Controllers
Use them when you want to use traditional MVC architecture
Solution to your problem
You don't register controllers as routes unless you want a specific 'named' route for a controller action.
Rather than create a route for your controllers actions, just register your controller:
Route::controller('user');
Now your controller is registered, you can navigate to http://localhost/mysite/public/user
and your get_index
will be run.
You can also register all controllers in one go:
Route::controller(Controller::detect());
you must be using Laravel 5 the command
class User_Controller extends Controller {
public $restful = true;
public function get_index(){
return View('user.index');
}
}
and in routes.php
Route::get('/', function()
{
return view('home.index');
});
Route::get('user', function()
{
return view('user.index');
});
Laravel 5 command changes for view and controller see the documentation i was having same error before