Laravel 5 - 异常'LogicException',消息'无法准备路由

时间:2016-11-28 20:20:40

标签: php laravel routes closures artisan

我不知道为什么但是在某些时候我尝试登录页面时收到此错误。

  

异常'LogicException',消息'无法准备路由   [api / user]用于序列化。使用闭包。'

这是我在日志中找到的:

exception 'LogicException' with message 'Unable to prepare route [api/user] for serialization. Uses Closure.' in /Applications/MAMP/htdocs/Tog/bootstrap/cache/compiled.php:8831
Stack trace:
#0 /Applications/MAMP/htdocs/Tog/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php(61): Illuminate\Routing\Route->prepareForSerialization()
#1 [internal function]: Illuminate\Foundation\Console\RouteCacheCommand->fire()
#2 /Applications/MAMP/htdocs/Tog/bootstrap/cache/compiled.php(1271): call_user_func_array(Array, Array)
#3 /Applications/MAMP/htdocs/Tog/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#4 /Applications/MAMP/htdocs/Tog/vendor/symfony/console/Command/Command.php(254): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /Applications/MAMP/htdocs/Tog/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /Applications/MAMP/htdocs/Tog/vendor/symfony/console/Application.php(820): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /Applications/MAMP/htdocs/Tog/vendor/symfony/console/Application.php(187): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Foundation\Console\RouteCacheCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /Applications/MAMP/htdocs/Tog/vendor/symfony/console/Application.php(118): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /Applications/MAMP/htdocs/Tog/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /Applications/MAMP/htdocs/Tog/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 {main}

您能否向我解释发生了什么?我该如何解决?

这是路线:

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::get('admin', function () {
    return view('admin_template');
});

// route to show the login form
Route::get('login', array('uses' => 'HomeController@showLogin'));

// route to process the form
Route::post('login', array('uses' => 'HomeController@doLogin'));

谢谢:)

1 个答案:

答案 0 :(得分:0)

摆脱阵列,改为使用它:

// route to show the login form
Route::get('login', 'HomeController@showLogin'); 

// route to process the form 
Route::post('login', 'HomeController@doLogin');