Mohammad
Mohammad

Reputation: 660

laravel 4.1 Controller method .... not found

i have this code but my Method not find ?

Route.php

Route::controller('Basic', 'BasicController');

BasicController.php

class BasicController extends BaseController {

    public function getIndex()
    {
        return View::make('hello');
    }

    public function getTest()
    {
        return 'test';
    }
}

when i call test from browser : `http://mydomain.dev/Basic/Test Not Work !
and get this error :

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
Controller method [Test] not found.

open: /var/www/mydomain.dev/vendor/laravel/framework/src/Illuminate/Routing/Controller.php
 * @param  array   $parameters
 * @return mixed
 *
 * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
 */
public function missingMethod($method, $parameters = array())
{
    throw new NotFoundHttpException("Controller method [{$method}] not found.");
}

Why ?

My laravel version is 4.1.8

Upvotes: 2

Views: 6284

Answers (1)

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87789

If you execute

artisan routes

You probably will see those routes

+--------+--------------------------------------------------------+------------+--------------------------------+----------------+---------------+
| Domain | URI                                                    | Name       | Action                         | Before Filters | After Filters |
+--------+--------------------------------------------------------+------------+--------------------------------+----------------+---------------+
|        | GET Basic/index/{one?}/{two?}/{three?}/{four?}/{five?} |            | BasicController@getIndex       |                |               |
|        | GET Basic                                              |            | BasicController@getIndex       |                |               |
|        | GET Basic/test/{one?}/{two?}/{three?}/{four?}/{five?}  |            | BasicController@getTest        |                |               |
|        | GET Basic/{_missing}                                   |            | BasicController@missingMethod  |                |               |
|        | GET test                                               |            | Closure                        |                |               |

If you say that your index is working:

So you need hit the route

http://mydomain.dev/Basic/test

and not

http://mydomain.dev/Basic/Test

Upvotes: 4

Related Questions