src
1 year ago
LICENSE
2 years ago
NOTICE
2 years ago
README.md
2 years ago
autoload.php
2 years ago
functions.php
7 months ago
README.md
93 lines
| 1 | Opis Closure |
| 2 | ==================== |
| 3 | [](https://github.com/opis/closure/actions](https://github.com/opis/closure/actions](https://github.com/opis/closure/actions) |
| 4 | [](https://packagist.org/packages/opis/closure](https://packagist.org/packages/opis/closure](https://packagist.org/packages/opis/closure) |
| 5 | [](https://packagist.org/packages/opis/closure](https://packagist.org/packages/opis/closure](https://packagist.org/packages/opis/closure) |
| 6 | [](https://packagist.org/packages/opis/closure](https://packagist.org/packages/opis/closure](https://packagist.org/packages/opis/closure) |
| 7 | |
| 8 | Serializable closures |
| 9 | --------------------- |
| 10 | **Opis Closure** is a library that aims to overcome PHP's limitations regarding closure |
| 11 | serialization by providing a wrapper that will make all closures serializable. |
| 12 | |
| 13 | **The library's key features:** |
| 14 | |
| 15 | - Serialize any closure |
| 16 | - Serialize arbitrary objects |
| 17 | - Doesn't use `eval` for closure serialization or unserialization |
| 18 | - Works with any PHP version that has support for closures |
| 19 | - Supports PHP 7 syntax |
| 20 | - Handles all variables referenced/imported in `use()` and automatically wraps all referenced/imported closures for |
| 21 | proper serialization |
| 22 | - Handles recursive closures |
| 23 | - Handles magic constants like `__FILE__`, `__DIR__`, `__LINE__`, `__NAMESPACE__`, `__CLASS__`, |
| 24 | `__TRAIT__`, `__METHOD__` and `__FUNCTION__`. |
| 25 | - Automatically resolves all class names, function names and constant names used inside the closure |
| 26 | - Track closure's residing source by using the `#trackme` directive |
| 27 | - Simple and very fast parser |
| 28 | - Any error or exception, that might occur when executing an unserialized closure, can be caught and treated properly |
| 29 | - You can serialize/unserialize any closure unlimited times, even those previously unserialized |
| 30 | (this is possible because `eval()` is not used for unserialization) |
| 31 | - Handles static closures |
| 32 | - Supports cryptographically signed closures |
| 33 | - Provides a reflector that can give you information about the serialized closure |
| 34 | - Provides an analyzer for *SuperClosure* library |
| 35 | - Automatically detects when the scope and/or the bound object of a closure needs to be serialized |
| 36 | in order for the closure to work after deserialization |
| 37 | |
| 38 | ## Documentation |
| 39 | |
| 40 | The full documentation for this library can be found [here][documentation]. |
| 41 | |
| 42 | ## License |
| 43 | |
| 44 | **Opis Closure** is licensed under the [MIT License (MIT)][license]. |
| 45 | |
| 46 | ## Requirements |
| 47 | |
| 48 | * PHP ^5.4 || ^7.0 || ^8.0 |
| 49 | |
| 50 | ## Installation |
| 51 | |
| 52 | **Opis Closure** is available on [Packagist] and it can be installed from a |
| 53 | command line interface by using [Composer]. |
| 54 | |
| 55 | ```bash |
| 56 | composer require opis/closure |
| 57 | ``` |
| 58 | |
| 59 | Or you could directly reference it into your `composer.json` file as a dependency |
| 60 | |
| 61 | ```json |
| 62 | { |
| 63 | "require": { |
| 64 | "opis/closure": "^3.5" |
| 65 | } |
| 66 | } |
| 67 | ``` |
| 68 | |
| 69 | ### Migrating from 2.x |
| 70 | |
| 71 | If your project needs to support PHP 5.3 you can continue using the `2.x` version |
| 72 | of **Opis Closure**. Otherwise, assuming you are not using one of the removed/refactored classes or features(see |
| 73 | [CHANGELOG]), migrating to version `3.x` is simply a matter of updating your `composer.json` file. |
| 74 | |
| 75 | ### Semantic versioning |
| 76 | |
| 77 | **Opis Closure** follows [semantic versioning][SemVer] specifications. |
| 78 | |
| 79 | ### Arbitrary object serialization |
| 80 | |
| 81 | We've added this feature in order to be able to support the serialization of a closure's bound object. |
| 82 | The implementation is far from being perfect, and it's really hard to make it work flawless. |
| 83 | We will try to improve this, but we can't guarantee anything. |
| 84 | So our advice regarding the `Opis\Closure\serialize|unserialize` functions is to use them with caution. |
| 85 | |
| 86 | |
| 87 | [documentation]: https://www.opis.io/closure "Opis Closure" |
| 88 | [license]: http://opensource.org/licenses/MIT "MIT License" |
| 89 | [Packagist]: https://packagist.org/packages/opis/closure "Packagist" |
| 90 | [Composer]: https://getcomposer.org "Composer" |
| 91 | [SemVer]: http://semver.org/ "Semantic versioning" |
| 92 | [CHANGELOG]: https://github.com/opis/closure/blob/master/CHANGELOG.md "Changelog" |
| 93 |