mirror of
https://github.com/danog/PHPStruct.git
synced 2024-11-26 19:54:38 +01:00
Create gh-pages branch via GitHub
This commit is contained in:
parent
c757553c79
commit
3f97b3dd26
@ -34,7 +34,8 @@
|
||||
|
||||
<p>PHP implementation of Python's struct module.</p>
|
||||
|
||||
<p>This library was created to help me develop a <a href="https://github.com/danog/MadelineProto">client for the mtproto protocol</a>. </p>
|
||||
<p>This library was created to help me develop a <a href="https://github.com/danog/MadelineProto">client for the mtproto protocol</a>.<br>
|
||||
It supports php 5.6, php 7 and HHVM. </p>
|
||||
|
||||
<p>The functions and the formats are exactly the ones used in python's struct
|
||||
(<a href="https://docs.python.org/3/library/struct.html">https://docs.python.org/3/library/struct.html</a>)</p>
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "PHPStruct",
|
||||
"tagline": " PHP implementation of Python's struct module.",
|
||||
"body": "# PHPStruct class\r\n\r\n[![Build Status](https://travis-ci.org/danog/PHPStruct.svg?branch=master)](https://travis-ci.org/danog/PHPStruct)\r\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/7b91e30ec89a4313bdb34766ea990113)](https://www.codacy.com/app/daniil-gentili-dg/PHPStruct?utm_source=github.com&utm_medium=referral&utm_content=danog/PHPStruct&utm_campaign=Badge_Grade)\r\n[![License](https://img.shields.io/packagist/l/danog/phpstruct.svg?maxAge=2592000?style=flat-square)](https://opensource.org/licenses/MIT)\r\n[![Packagist download count](https://img.shields.io/packagist/dm/danog/phpstruct.svg?maxAge=2592000?style=flat-square)](https://packagist.org/packages/danog/phpstruct)\r\n[![Packagist](https://img.shields.io/packagist/v/danog/PHPStruct.svg?maxAge=2592000?style=flat-square)](https://packagist.org/packages/danog/phpstruct)\r\n[![HHVM Status](http://hhvm.h4cc.de/badge/danog/phpstruct.svg?style=flat-square)](http://hhvm.h4cc.de/package/danog/phpstruct)\r\n[![StyleCI](https://styleci.io/repos/62454134/shield)](https://styleci.io/repos/62454134)\r\n\r\nLicensed under MIT.\r\n\r\nPHP implementation of Python's struct module.\r\n\r\nThis library was created to help me develop a [client for the mtproto protocol](https://github.com/danog/MadelineProto). \r\n\r\nThe functions and the formats are exactly the ones used in python's struct \r\n(https://docs.python.org/3/library/struct.html)\r\n\r\nThis library can be used to pack/unpack strings, ints, floats, chars and bools into bytes.\r\nIt has lots of advantages over PHP's native implementation of pack and unpack, such as: \r\n* Custom byte endianness.\r\n* Lots of useful formats that aren't present in the native implementation.\r\n* The syntax of the format string of pack and unpack is the same as in python's struct module.\r\n* The result of unpack is normal numerically indexed array that starts from 0 like it should.\r\n* The result of unpack has type casted values (int for integer formats, bool for boolean formats, float for float formats and string for all of the other formats).\r\n* The calcsize function is implemented.\r\n* The q and Q formats can be used even on 32 bit systems (the downside is limited precision).\r\n* Padding is supported for the @ modifier.\r\n\r\nFor now custom byte size may not work properly on certain machines for the f and d formats.\r\n\r\n## Installation\r\n\r\nInstall using composer:\r\n```\r\ncomposer require danog/phpstruct\r\n```\r\n\r\n# Usage\r\nDynamic (recommended) \r\n```\r\nrequire('vendor/autoload.php');\r\n$struct = new \\danog\\PHP\\StructClass();\r\n$pack = $struct->pack(\"2cxi\", \"ab\", 44);\r\n$unpack = $struct->unpack(\"2cxi\", $pack);\r\nvar_dump($unpack);\r\n$count = $struct->calcsize(\"2cxi\");\r\n``` \r\n\r\nDynamic (while specifying format string during istantiation) \r\n```\r\nrequire('vendor/autoload.php');\r\n$struct = new \\danog\\PHP\\StructClass(\"2cxi\");\r\n$pack = $struct->pack(\"ab\", 44);\r\n$unpack = $struct->unpack($pack);\r\nvar_dump($unpack);\r\n$count = $struct->size;\r\n$formatstring = $struct->format;\r\n```\r\n\r\nStatic\r\n\r\n\r\n```\r\nrequire('vendor/autoload.php');\r\n$pack = \\danog\\PHP\\Struct::pack(\"2cxi\", \"ab\", 44);\r\n$unpack = \\danog\\PHP\\Struct::unpack(\"2cxi\", $pack);\r\nvar_dump($unpack);\r\n$count = \\danog\\PHP\\Struct::calcsize(\"2cxi\");\r\n```\r\n\r\n\r\n[Daniil Gentili](http://daniil.it)\r\n",
|
||||
"body": "# PHPStruct class\r\n\r\n[![Build Status](https://travis-ci.org/danog/PHPStruct.svg?branch=master)](https://travis-ci.org/danog/PHPStruct)\r\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/7b91e30ec89a4313bdb34766ea990113)](https://www.codacy.com/app/daniil-gentili-dg/PHPStruct?utm_source=github.com&utm_medium=referral&utm_content=danog/PHPStruct&utm_campaign=Badge_Grade)\r\n[![License](https://img.shields.io/packagist/l/danog/phpstruct.svg?maxAge=2592000?style=flat-square)](https://opensource.org/licenses/MIT)\r\n[![Packagist download count](https://img.shields.io/packagist/dm/danog/phpstruct.svg?maxAge=2592000?style=flat-square)](https://packagist.org/packages/danog/phpstruct)\r\n[![Packagist](https://img.shields.io/packagist/v/danog/PHPStruct.svg?maxAge=2592000?style=flat-square)](https://packagist.org/packages/danog/phpstruct)\r\n[![HHVM Status](http://hhvm.h4cc.de/badge/danog/phpstruct.svg?style=flat-square)](http://hhvm.h4cc.de/package/danog/phpstruct)\r\n[![StyleCI](https://styleci.io/repos/62454134/shield)](https://styleci.io/repos/62454134)\r\n\r\nLicensed under MIT.\r\n\r\nPHP implementation of Python's struct module.\r\n\r\nThis library was created to help me develop a [client for the mtproto protocol](https://github.com/danog/MadelineProto). \r\nIt supports php 5.6, php 7 and HHVM. \r\n\r\nThe functions and the formats are exactly the ones used in python's struct \r\n(https://docs.python.org/3/library/struct.html)\r\n\r\nThis library can be used to pack/unpack strings, ints, floats, chars and bools into bytes.\r\nIt has lots of advantages over PHP's native implementation of pack and unpack, such as: \r\n* Custom byte endianness.\r\n* Lots of useful formats that aren't present in the native implementation.\r\n* The syntax of the format string of pack and unpack is the same as in python's struct module.\r\n* The result of unpack is normal numerically indexed array that starts from 0 like it should.\r\n* The result of unpack has type casted values (int for integer formats, bool for boolean formats, float for float formats and string for all of the other formats).\r\n* The calcsize function is implemented.\r\n* The q and Q formats can be used even on 32 bit systems (the downside is limited precision).\r\n* Padding is supported for the @ modifier.\r\n\r\nFor now custom byte size may not work properly on certain machines for the f and d formats.\r\n\r\n## Installation\r\n\r\nInstall using composer:\r\n```\r\ncomposer require danog/phpstruct\r\n```\r\n\r\n# Usage\r\nDynamic (recommended) \r\n```\r\nrequire('vendor/autoload.php');\r\n$struct = new \\danog\\PHP\\StructClass();\r\n$pack = $struct->pack(\"2cxi\", \"ab\", 44);\r\n$unpack = $struct->unpack(\"2cxi\", $pack);\r\nvar_dump($unpack);\r\n$count = $struct->calcsize(\"2cxi\");\r\n``` \r\n\r\nDynamic (while specifying format string during istantiation) \r\n```\r\nrequire('vendor/autoload.php');\r\n$struct = new \\danog\\PHP\\StructClass(\"2cxi\");\r\n$pack = $struct->pack(\"ab\", 44);\r\n$unpack = $struct->unpack($pack);\r\nvar_dump($unpack);\r\n$count = $struct->size;\r\n$formatstring = $struct->format;\r\n```\r\n\r\nStatic\r\n\r\n\r\n```\r\nrequire('vendor/autoload.php');\r\n$pack = \\danog\\PHP\\Struct::pack(\"2cxi\", \"ab\", 44);\r\n$unpack = \\danog\\PHP\\Struct::unpack(\"2cxi\", $pack);\r\nvar_dump($unpack);\r\n$count = \\danog\\PHP\\Struct::calcsize(\"2cxi\");\r\n```\r\n\r\n\r\n[Daniil Gentili](http://daniil.it)\r\n",
|
||||
"note": "Don't delete this file! It's used internally to help with page regeneration."
|
||||
}
|
Loading…
Reference in New Issue
Block a user