Your configuration files are not serializable
sickleper opened this issue · 6 comments
laravel 6 , php 7.2
sudo php artisan config:cache
LogicException : Your configuration files are not serializable.
at /var/www/html/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php:71
67| require $configPath;
68| } catch (Throwable $e) {
69| // $this->files->delete($configPath);
70|
71| throw new LogicException('Your configuration files are not serializable.', 0, $e);
72| }
73|
74| $this->info('Configuration cached successfully!');
75| }
Exception trace:
1 Error::("Call to undefined method Closure::__set_state()")
/var/www/html/laravel/bootstrap/cache/config.php:298
Triggered by
// settings group
'setting_group' => function() {
return 'user_'.auth()->id();
Thanks for reporting. what about if you use a class instead of closure for setting group
namespace App;
class SettingGroup {
public function handle() {
return 'user_'.auth()->id();
}
}
'setting_group' => 'App\SettingGroup'
please try, I will update the readme if it works.
no joy , returns default ..
cache key = default,
tried Config::set() returns default;
probably best setting userid value by cache key? no possible way to run function from config..
got it fixed for me ..
class SetSettingMiddleware
{
public function handle($request, Closure $next)
{
$setting_group = function() {
return 'user_'.auth()->id();
}
Config::set('app_settings.setting_group', $setting_group);
return $next($request);
}
}
// settings group
'setting_group' => '',
Same issue, and with closure for select.
Maybe make an Interface for parametr, eg:
'inputs' => [
[
'name' => 'from_email',
'type' => 'email',
'label' => 'From Email',
'placeholder' => 'Application from email',
'rules' => 'required|email',
],
]
to
interface SettingsField(){
public function getName();
public function getType();
...
}
------------
'inputs' => [
\App\Settings\EmailField::class,
\App\Settings\NameField::class,
]
as an option behaivor, for specify fields with logic.
I have the same issue. Can you help?
This issue still exist by default
below solution is works:
open confi/app_settings.php, find & replace:
'setting_group' => 'App\SettingGroup'
or
'setting_group' => '',