1
votes

I don't know why but at certain point I receive this error when I try to go on login page.

exception 'LogicException' with message 'Unable to prepare route [api/user] for serialization. Uses Closure.'

This is what I found in a log:

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}

Could you please explain to me what's happened and how can I resolve it?

This is the routes:

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

Thanks :)

1
Show your routes.php with the route for api/useraynber
Can you edit your question with that? It's hard to read in a comment.aynber
By the way, i see you are doing a login form and stuff like that. i would recommend you to simply run php artisan make:auth, and create this for you+ lots of more useful things.GabMic

1 Answers

0
votes

Get rid of the array, use this instead:

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

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