joomla/compat
最新稳定版本:1.2.0
Composer 安装命令:
composer require joomla/compat
包简介
Joomla Compat Package
关键字:
README 文档
README
This is a simple package that contains forward compatibility classes and interfaces that are registered to the global namespace
Deprecated
The joomla/compat package has been deprecated. No further updates are planned.
JsonSerializable
JsonSerializable is a PHP 5.4 interface that allows you to specify what data to serialize to JSON when you json_encode an object that implements the interface.
Usage
Since this is a PHP 5.4 interface, the jsonSerialize() method does not get called automatically when json_encode-ing an instance of the class when used in 5.3. To work around this, simply call the jsonSerialize() method directly when passing it to json_encode. This is forward-compatible with PHP 5.4.
Note in some instances of PHP 5.5 from Debian the interface is also missing (see http://stackoverflow.com/questions/18239405/php-fatal-error-call-to-undefined-function-json-decode) which will also require this interface to be included.
class MyClass implements \JsonSerializable { /** * @var array Holds the data this class uses. */ protected $data; public function __construct(array $data) { $this->data = $data; } public function jsonSerialize() { return $this->data; } } $obj = new MyClass(array('sample', 'data', 'to', 'encode')); $encoded = json_encode($obj->jsonSerialize());
Installation via Composer
Add "joomla/compat": "~1.0" to the require block in your composer.json and then run composer install.
{
"require": {
"joomla/compat": "~1.0"
}
}
Alternatively, you can simply run the following from the command line:
composer require joomla/compat "~1.0"
统计信息
- 总下载量: 156.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2013-03-01