My Routes are Returning a 404, How can I Fix Them?

前端 未结 18 1169
栀梦
栀梦 2020-12-23 10:44

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

18条回答
  •  悲&欢浪女
    2020-12-23 11:32

    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());
    

提交回复
热议问题