PHP code example of flashport / laravel-json-marshaller

1. Go to this page and download the library: Download flashport/laravel-json-marshaller 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/ */

    

flashport / laravel-json-marshaller example snippets


/**
 * The attributes that should be cast.
 *
 * @var array<string, string>
 */
protected $casts = [
    'metadata'      => JsonMarshallable::class . ":" . Metadata::class,
    'customFields'  => JsonMarshallable::class . ":" . CustomField::class,
    'active'        => 'bool',
];


use LaravelJsonMarshaller\Castables\AsJsonMarshallable;

class CustomField extends AsJsonMarshallable
{
    //...
}

/**
 * The attributes that should be cast.
 *
 * @var array<string, string>
 */
protected $casts = [
    'metadata'      => Metadata::class,
    'customFields'  => CustomField::class,
    'active'        => 'bool',
];