Commit e0fac8e3 authored by Anton Smirnov's avatar Anton Smirnov
Browse files

Docs & Changelog for 1.5

parent 22254408
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5,6 +5,9 @@
/vendor/
/composer.lock

# docs
/docs/index.html

# tests
/reports
/.phpunit.result.cache
+10 −3
Original line number Diff line number Diff line
@@ -2,12 +2,19 @@

## 1.x

### 1.5.0

*Feb 3, 2021*

* Added stream API
* Added GMP support

### 1.4.0

*Nov 10, 2020*

* Make spec compliant BitTorrent code simpler: `null` and `false` values are now skipped on encoding
* Add `'dictType'` alias for `'dictionaryType'` for 2.3 compatibility
* Made spec compliant BitTorrent code simpler: `null` and `false` values are now skipped on encoding
* Added `'dictType'` alias for `'dictionaryType'` for 2.3 compatibility

### 1.3.0

@@ -49,7 +56,7 @@

*Mar 22, 2017*

* Add stdClass as list/dict decoding option
* Added stdClass as list/dict decoding option

### 1.0.0

+35 −7
Original line number Diff line number Diff line
@@ -82,6 +82,11 @@ Objects

    $encoded = Bencode::encode(new ToString()); // "11:I am string"

    // Since 1.5 and 2.5: GMP object becomes integer
    $encoded = Bencode::encode([
        'gmp' => gmp_pow(2, 96),
    ]); // "d3:gmpi79228162514264337593543950336ee"

BencodeSerializable
-------------------

@@ -138,6 +143,13 @@ Decoding
    ]);
    // default value for both types is 'array'. you can also use 'object' for stdClass

    // Since 1.5 and 2.5:
    // Enable useGMP option to decode huge integers to the GMP object
    $data = Bencode::decode(
        "d3:gmpi79228162514264337593543950336ee",
        ['useGMP' => true]
    ]; // ['gmp' => gmp_init('79228162514264337593543950336')]

Working with files
==================

@@ -147,8 +159,24 @@ Working with files

    use SandFox\Bencode\Bencode;

    $data = Bencode::load('testfile.torrent'); // load data from bencoded file
    Bencode::dump('testfile.torrent', $data); // save data to the bencoded file
    // load data from a bencoded file
    $data = Bencode::load('testfile.torrent');
    // save data to a bencoded file
    Bencode::dump('testfile.torrent', $data);

Working with streams
====================

.. code-block:: php

    <?php

    use SandFox\Bencode\Bencode;

    // load data from a bencoded seekable readable stream
    $data = Bencode::decodeStream(fopen('...', 'r'));
    // save data to a bencoded writable stream or to a new php://temp if no stream is specified
    Bencode::encodeToStream($data, fopen('...', 'w'));

License
=======
@@ -160,13 +188,13 @@ The library is available as open source under the terms of the `MIT License`_.
.. _JsonSerializable:   http://php.net/manual/en/class.jsonserializable.php
.. _MIT License:        https://opensource.org/licenses/MIT

.. |Packagist|  image:: https://img.shields.io/packagist/v/sandfoxme/bencode.svg
.. |Packagist|  image:: https://img.shields.io/packagist/v/sandfoxme/bencode.svg?style=flat-square
   :target:     https://packagist.org/packages/sandfoxme/bencode
.. |GitHub|     image:: https://img.shields.io/badge/get%20on-GitHub-informational.svg?logo=github
.. |GitHub|     image:: https://img.shields.io/badge/get%20on-GitHub-informational.svg?style=flat-square&logo=github
   :target:     https://github.com/arokettu/bencode
.. |GitLab|     image:: https://img.shields.io/badge/get%20on-Gitlab-informational.svg?logo=gitlab
.. |GitLab|     image:: https://img.shields.io/badge/get%20on-Gitlab-informational.svg?style=flat-square&logo=gitlab
   :target:     https://gitlab.com/sandfox/bencode
.. |Bitbucket|  image:: https://img.shields.io/badge/get%20on-Bitbucket-informational.svg?logo=bitbucket
.. |Bitbucket|  image:: https://img.shields.io/badge/get%20on-Bitbucket-informational.svg?style=flat-square&logo=bitbucket
   :target:     https://bitbucket.org/sandfox/bencode
.. |Gitea|      image:: https://img.shields.io/badge/get%20on-Gitea-informational.svg
.. |Gitea|      image:: https://img.shields.io/badge/get%20on-Gitea-informational.svg?style=flat-square&logo=gitea
   :target:     https://git.sandfox.dev/sandfox/bencode