dataphile
dataphile

Reputation: 352

laravel 4 simple route not working

I have a working laravel installation to which I wanted to add a route but it wouldn't work.

Route::get('asdf', function() {return "asdf";});

All the other routes work but new ones don't, not even controller ones. I have just tried to simplify an example above to post here.

  1. I created a github project with the full project laravella\laravella
  2. Cloned the project
  3. Deleted compiled.php
  4. Ran composer install
  5. Ran php artisan dump-autoload
  6. Ran php artisan serve --port 80

The server console reports this error :

[Fri Jul 12 10:11:11 2013] 127.0.0.1:51042 Invalid request (Unexpected EOF)
[Fri Jul 12 10:11:11 2013] 127.0.0.1:51043 Invalid request (Unexpected EOF)
[Fri Jul 12 10:11:11 2013] 127.0.0.1:51044 Invalid request (Unexpected EOF)

Below is the log.

Thanks.

[2013-07-12 08:29:44] log.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in C:\xampp\htdocs\lv\laravella\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Controller.php:290
Stack trace:
#0 [internal function]: Illuminate\Routing\Controllers\Controller->missingMethod(Array)
#1 C:\xampp\htdocs\lv\laravella\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Controller.php(138): call_user_func_array(Array, Array)
#2 C:\xampp\htdocs\lv\laravella\vendor\laravel\framework\src\Illuminate\Routing\Controllers\Controller.php(115): Illuminate\Routing\Controllers\Controller->callMethod('missingMethod', Array)
#3 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(4741): Illuminate\Routing\Controllers\Controller->callAction(Object(Illuminate\Foundation\Application), Object(Illuminate\Routing\Router), 'missingMethod', Array)
#4 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Array)
#5 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(7810): call_user_func_array(Object(Closure), Array)
#6 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(7797): Illuminate\Routing\Route->callCallable()
#7 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(4752): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#8 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(480): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#9 C:\xampp\htdocs\lv\laravella\bootstrap\compiled.php(469): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#10 C:\xampp\htdocs\lv\laravella\public\index.php(49): Illuminate\Foundation\Application->run()
#11 C:\xampp\htdocs\lv\laravella\server.php(19): require_once('C:\xampp\htdocs...')
#12 {main} [] []

Upvotes: 0

Views: 3625

Answers (1)

Trying Tobemyself
Trying Tobemyself

Reputation: 3668

Make sure Route::get('asdf', function() {return "asdf";}); is above controller routes if you have any because controller routes are greedy they won't let Route::get() handle their routes as it should have.

Edit Looking at your github clone routes.php its like

Route::controller('account', 'AccountController');
Route::controller('/', 'HomeController');
Route::get('asdf', function() {return "asdf";});

so in order to make your Route::get('asdf','...'); to work just add it above controller routes ex-

Route::get('asdf', function() {return "asdf";});
Route::controller('account', 'AccountController');
Route::controller('/', 'HomeController');

And it will work

Upvotes: 1

Related Questions