cornford / bencoded
An easy way to use bencoding in Laravel.
Requires
- php: >=7.2
Requires (Dev)
- mockery/mockery: ^1.2.4
- phpspec/phpspec: ^6.0
- phpunit/phpunit: ^8.4
This package is auto-updated.
Last update: 2024-10-29 06:18:29 UTC
README
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