nirsharony said:
Route::controller('notWorking', 'NotWorkingController');
When I try to access the URI using: http://localhost:8000/notWorking
From the docs:
If your controller action contains multiple words, you may access the action using "dash" syntax in the URI. For example, the following controller action on our UserController would respond to the users/admin-profile URI:
public function getAdminProfile() {}
You should try http://localhost:8000/not-working
That didn't solve the problem.... :-(
I am getting the same error message
After checking php artisan routes, I found out that the following request gets to my function: http://localhost:8000/notWorking/not-working
This is not what I want. I would like the definition in routes.php to handle a simple call to: http://localhost:8000/not-working
Does that mean that I am misusing the Route::controller function?
Nir
It's looking for your index action by default. The action it looks for depends upon the verb you pass (GET, POST, PATCH etc). I think you want a named route such as
Route::get('/not-working', array('uses' => 'NotWorkingController@notworking', 'as' => 'notworking'));
The line in routes.php is: Route::controller('/not-working', 'NotWorkingController');
This is what php artisan routes tell me about my definition:
You will notice the double not-working/not-working for the GET and HEAD requests. Why is that? What needs to be done in order for the request to just be: http://localhost:8000/not-working ?
change your function
public function getNotWorking () {
///code sample here
}
to
public function getIndex () {
///code sample...
}
Then use the route
Route::get('/not-working', 'NotWorkingController@getIndex');
Hi ndy40,
I know that this solution works, but I was looking for a solution that I found to be "cleaner" which is the RESTfull Controller mechanism.
At the end of the day, it doesn't really matter as long as the code works and it is easy to manage. Instead of struggling to get RESTfull controllers to work, I will simply use the regular Route::get method.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community