closure: InvalidArgumentException : Unknown setter 'date'

Hello,

I have an issue with Carbon dates that are serialized through GitHub - opis/closure: Serialize closures (anonymous functions)

Laravel version: 6.11.0 Carbon version: 2.28.0 PHP version: 7.3.10 Opis/Closure version: 3.5.1

The problem seems to occur after upgrading to Laravel 6 and therefor upgraded from Carbon 1 to Carbon 2.

I wasn’t sure if this belongs to the Carbon or Opis issues. So I’ve posted this question on both. (InvalidArgumentException : Unknown setter ‘date’ · Issue #1988 · briannesbitt/Carbon · GitHub)

When a closure is serialized:

return serialize(new SerializableClosure($closure, true));

I get this error: InvalidArgumentException : Unknown setter 'date’.

This boils down to /nesbot/carbon/src/Carbon/Traits/Date.php:1166.

I’ve googled this issue for some time now and I believe it has got a lot to do with the depreciation of serializeUsing. As found in issue Provide an alternative to serializeUsing to Laravel users · Issue #1870 · briannesbitt/Carbon · GitHub. @driesvints

However after reading multiple threads I’m not able to find a solution. I really hope someone can help me steering me to the right direction 🙏.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 32 (12 by maintainers)

Most upvoted comments

Thank you. I was happy to discover this library.

This can be closed I guess to be handled in Carbon.

Is pretty similar with your solution, but I’ll send you a PR.

reading multiple threats

Multiple threads, I hope!