Package Data | |
---|---|
Maintainer Username: | taylorotwell |
Maintainer Contact: | taylor@laravel.com (Taylor Otwell) |
Package Create Date: | 2021-09-07 |
Package Last Update: | 2024-11-09 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-10 15:00:36 |
Package Statistics | |
---|---|
Total Downloads: | 186,655,456 |
Monthly Downloads: | 7,399,551 |
Daily Downloads: | 130,583 |
Total Stars: | 524 |
Total Watchers: | 16 |
Total Forks: | 33 |
Total Open Issues: | 2 |
This project is a fork of the excellent opis/closure: 3.x package. At Laravel, we decided to fork this package as the upcoming version 4.x is a complete rewrite on top of the FFI extension. As Laravel is a web framework, and FFI is not enabled by default in web requests, this fork allows us to keep using the
3.x
series while adding support for new PHP versions.
Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.
Requires PHP 7.4+
First, install Laravel Serializable Closure via the Composer package manager:
composer require laravel/serializable-closure
You may serialize a closure this way:
use Laravel\SerializableClosure\SerializableClosure;
$closure = fn () => 'james';
// Recommended
SerializableClosure::setSecretKey('secret');
$serialized = serialize(new SerializableClosure($closure));
$closure = unserialize($serialized)->getClosure();
echo $closure(); // james;
Creating anonymous classes within closures is not supported.
Thank you for considering contributing to Serializable Closure! The contribution guide can be found in the Laravel documentation.
In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.
Please review our security policy on how to report security vulnerabilities.
Serializable Closure is open-sourced software licensed under the MIT license.