cornford/bencoded

An easy way to use bencoding in Laravel.

v3.1.0 2020-01-30 11:40 UTC

This package is auto-updated.

Last update: 2024-03-29 04:18:32 UTC


README

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality

For Laravel 5.x, check version 2.0.0

For Laravel 4.x, check version 1.0.0

Think of Bencoded as an easy way to use bencoding with Laravel. These include:

  • Bencoded::encode
  • Bencoded::decode

Installation

Begin by installing this package through Composer. Edit your project's composer.json file to require cornford/bencoded.

"require": {
    "cornford/bencoded": "2.*"
}

Next, update Composer from the Terminal:

composer update

Once this operation completes, the next step is to add the service provider. Open app/config/app.php, and add a new item to the providers array.

'Cornford\Bencoded\Providers\BencodedServiceProvider',

The final step is to introduce the facade. Open app/config/app.php, and add a new item to the aliases array.

'Bencoded'         => 'Cornford\Bencoded\Facades\BencodedFacade',

That's it! You're all set to go.

Usage

It's really as simple as using the Bencoded class in any Controller / Model / File you see fit with:

Bencoded::

This will give you access to

Encode

The encode method encodes an item into a bencoding format.

Bencoded::encode([['name' => 'tom'], ['name' => 'jerry']]);

Decode

The decode method decodes a bencoding string into PHP types.

Bencoded::decode('ld4:name3:tomed4:name5:jerryee);

License

Bencoded is open-sourced software licensed under the MIT license