Laravel-filemanager: Call to undefined method Closure::__set_state()

Created on 25 May 2017  路  7Comments  路  Source: UniSharp/laravel-filemanager

Hi,
after php artisan config:cache I have an error:
[2017-05-25 10:34:01] production.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Closure::__set_state() in my-project/bootstrap/cache/config.php:773

config.php:
image

This error is because you put function into configs. Could you change it, to fix?
'user_field' => function () { return auth()->user()->id; },

I see you wrote a comment, that's not possible to use in Laravel 5.2. But what I have to do? Should I remove 'user_field' or what?

When change user_field to 'id' it works good.
Could you change default config user_fild value to 'id' instead of closure?

OS System & Version: Linux skey-Inspiron-5737 4.10.0-21-generic #23-Ubuntu SMP Fri Apr 28 16:14:22 UTC 2017 x86_64
Laravel Version: v5.4.23
File Manager Version: v1.7.7
imagick Extension: Not Install
gd Extension: Install

Most helpful comment

I resolved it by removing this: bootstrap/cache/config.php

All 7 comments

Hello @pderiy , Laravel suggested not using closures in config files, since they cannot be cached. The reason why we use closure as the value of 'user_field' is to demonstrate the flexibility of this package.

I had the same problem , on production server I tried to optimize Laravel ,but stoped here. any solution yet ? thanks!

Laravel:5.4
File Manager: unisharp/laravel-filemanager": "^1.7"
TinyMCE: 4.5.7.

I think, i found the solution, in the config/lfm.php file, set the key 'user_field' like this => \App\User::class or where ever you have the User model in laravel 5.4, i hope this help a lot
Once you make that, you can run php artisan optimize, then php artisan config:cache and then php artisan route:cache. The package must be at 1.7.* version on composer.json.

Set value of 'user_field' to 'id' can do the same.

Please upgrade to v1.8.1.

Does anyone know how to recover from this? I updated to 1.8.1 but artisan is still broken, I can't run any commands at all

Edit: Nevermind I found it, for those looking for a solution delete the bootstrap/cache/config.php file.

I resolved it by removing this: bootstrap/cache/config.php

Was this page helpful?
0 / 5 - 0 ratings