[Bug]: Serialization of 'Closure' is not allowed (httpClient property of EasyPostClient)
Software Version
v7.1.0
Language Version
PHP 8.3, Laravel
Operating System
macOS
What happened?
I have a project that uses easypost-php. When using v6.x everything works fine, but when upgrading to v7 I ran into problems. I'm using Laravel and attempting to store the EasyPostClient in a Laravel session. Once I try to save the client to the session via middleware I'm met with the following error: Serialization of 'Closure' is not allowed. I've determined it's due to the httpClient property of the EasyPostClient object containing a closure. Under normal use this is acceptable but when the Laravel session tries to serialize the EasyPostClient object...
public function handle($request, Closure $next)
{
// various other middleware code
$client = new EasyPostClient($apiKey);
$request->session()->put('client', $client);
}
It cannot do so because that's not possible in PHP.
What was expected?
We should explore potential solutions to the problem where we can retain an instance variable of the httpClient so it's tied to the EasyPostClient so it remains performant but allows for proper serialization so users that need to pass around a client can in all situations.
Sample Code
No response
Relevant logs
No response