1

I got some problem loading a class from a package so i try to run -as suggested by a lot of user- these commands in order to make my class searchable by my files:

php artisan optimize
php artisan config:cache 
php artisan route:cache

Last one command give me back this error as output:

[LogicException]
Unable to prepare route [/] for serialization. Uses Closure.

After this i run again my site and ive got this lovely mex:

Whoops, looks like something went wrong.

And i cant even browse my site now! what happend? How can I fix it?

JahStation
  • 893
  • 3
  • 15
  • 35

2 Answers2

1

You can't serialise a closure. Please see this answer. Exception: Serialization of 'Closure' is not allowed

Look fort some code where you have said

$xyz = function(){//etc} for your / route.

delboy1978uk
  • 12,118
  • 2
  • 21
  • 39
  • thats is a closure so: Route::get('/', function () { return view('welcome'); }); – JahStation May 22 '17 at 16:36
  • 1
    @JahStation that's correct. Even the default welcome route will not work when you try to cache the routes. – Sandeesh May 22 '17 at 17:19
  • ok ive cut the function and converted it to the classic format: `Route::get('/','UserController@welcome');` now the 3 commands runs without errors, but ive got still the same output from all site "something going wrong" now i add some debug option to see what happen – JahStation May 23 '17 at 09:28
  • If you are getting an HTTP 500 error response, check your PHP error_log and see what the error was this time. – delboy1978uk May 23 '17 at 11:28
  • thtas works for making the command workin....as suggested, but the 500error was resolved by the magic after check reply below. thanks a lot to all contributors – JahStation May 23 '17 at 15:24
0

this is a personal comment so take it as it is, a comment from a not expert user, but the 95% of my laravel's problem are solved by time..yes no workaround, just time to wait an magically something happen! this is tricky and it seem a no funny stuff to me! may it dependens from the caching system... or whatever, but is maybe the 5th or 6th time that i spent a lot of time for solving something that after a while is magically turned up again....

that problem of the post comes from me that trying to make working some classic class like form and html by html collective a pretty well documented api for using aliass on the front page.

i found several post that suggest to me to run the commands above; then strange problems comes out all was broken; i lost all days trying to perform something to solve it.... and now... it works again! without any mods without changing anything except the clousure... but only after several hours!

now with the site ok, i moved the clousure function to a standard controller! but i wrong the name of it so i delete it and i made another one... my routing still pointing to the old controller! but this time i will wait!

JahStation
  • 893
  • 3
  • 15
  • 35