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

Config cache fails with "Your configuration files are not serializable" due to "ip_selector" #64

Open
dev-ramchander opened this issue Jan 9, 2025 · 0 comments

Comments

@dev-ramchander
Copy link

image

When using the ipinfo configuration in Laravel 10 with a custom IP selector object, the php artisan config:cache command fails, throwing the error:

LogicException

Your configuration files are not serializable.

at vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigCacheCommand.php:73

The root cause is the direct instantiation of CustomIPSelector in the configuration array, as shown

'ipinfo' => [
    'access_token' => env('IPINFO_SECRET'),
    'ip_selector' => new CustomIPSelector(),
    'filter' => false,
    'no_except' => true,
],

Steps to Reproduce:

  1. Define the configuration as above.
  2. Run php artisan config:cache.
  3. Observe the error:
LogicException
Your configuration files are not serializable.

Workaround Attempt:
Replacing the instantiation with the class name works for php artisan config:cache:

'ipinfo' => [
    'access_token' => env('IPINFO_SECRET'),
    'ip_selector' => App\Helpers\CustomIPSelector::class,
    'filter' => false,
    'no_except' => true,
],

However, this leads to another error when using the ipinfo library:

Call to a member function getIP() on string

This happens because the library directly uses the ip_selector configuration value without instantiating the class.

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

1 participant