Support the ongoing development of Laravel.io →
posted 10 years ago
Requests
Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

That didn't solve the problem.... :-(

I am getting the same error message

Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

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'));
Last updated 2 years ago.
0

The line in routes.php is: Route::controller('/not-working', 'NotWorkingController');

This is what php artisan routes tell me about my definition:

  • GET|HEAD not-working/not-working/{one?}/{two?}/{three?}/{four?}/{five?} | | NotWorkingController@getNotWorking
  • GET|HEAD|POST|PUT|PATCH|DELETE not-working/{_missing} | | NotWorkingController@missingMethod

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 ?

Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

nirsharony nirsharony Joined 23 Aug 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.