1. Go to this page and download the library: Download tiny-blocks/serializer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tiny-blocks / serializer example snippets
namespace Example;
use TinyBlocks\Serializer\Serializer;
use TinyBlocks\Serializer\SerializerAdapter;
final readonly class Amount implements Serializer
{
use SerializerAdapter;
public function __construct(private float $value, private string $currency)
{
}
}
$amount = new Amount(value: 1.25, currency: 'USD');
$amount->toJson(); # {"value":1.25,"currency":"USD"}