chiiya / filament-access-control

Admin user, role and permission management for Laravel Filament
MIT License
192 stars 24 forks source link

php artisan optimize command fails #8

Closed jojostx closed 2 years ago

jojostx commented 2 years ago

I ran

php artisan optimize which is also run php artisan config:cache as part of it's commands.

on my terminal and i got a LogicException:

`LogicException : Your configuration files are not serializable.

at C:\xampp\htdocs{PROJECT}\vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigCacheCommand.php:68

64| require $configPath; 65| } catch (Throwable $e) { 66| $this->files->delete($configPath); 67| 68| throw new LogicException('Your configuration files are not serializable.', 0, $e); 69| } 70| 71| $this->info('Configuration cached successfully!'); 72| }

Exception trace:

1 Error::("Call to undefined method Closure::__set_state()") C:\xampp\htdocs{PROJECT}\bootstrap\cache\config.php:241

2 require() C:\xampp\htdocs{PROJECT}\vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigCacheCommand.php:64

Please use the argument -v to see more details.`

after doing some debugging and search on what the error was i came across this post on stackoverflow that explains what might be causing this error.

and after searching i found what I feel is the cause: `/* -------------------------------------------------------------------------- Password Rules
Rules for the password set during the passwort reset flow.
  */
25|         'password_rules' => [Password::min(8)],`

in the config file of the package at vendor\chiiya\filament-access-control\config\filament-access-control.php

reason for error:

Closure serialization is not allowed in Laravel and PHP at large. Look through your configuration files for any file where you used Closures and rewrite that piece of code using traditional functions.

chiiya commented 2 years ago

If you look at what Password::min(8) does, it's just a wrapper for 'min:8'. So replace it with:

'password_rules' => ['min:8'],

(assuming you published the config files)

chiiya commented 2 years ago

Should also be fixed in v1.3.4