Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Your configuration files are not serializable #23

Open
sickleper opened this issue Mar 2, 2020 · 6 comments
Open

Your configuration files are not serializable #23

sickleper opened this issue Mar 2, 2020 · 6 comments

Comments

@sickleper
Copy link

sickleper commented Mar 2, 2020

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();

@saqueib
Copy link
Member

saqueib commented Mar 3, 2020

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.

@sickleper
Copy link
Author

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..

@sickleper
Copy link
Author

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' => '',

@freebuu
Copy link

freebuu commented Dec 18, 2020

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.

@mabehiry
Copy link

I have the same issue. Can you help?

@sluxzer
Copy link

sluxzer commented Jul 1, 2021

This issue still exist by default

below solution is works:

open confi/app_settings.php, find & replace:

'setting_group' => 'App\SettingGroup'
or
'setting_group' => '',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants