PHP code example of marshmallow / metadata

1. Go to this page and download the library: Download marshmallow/metadata 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/ */

    

marshmallow / metadata example snippets


return [
    /*
     * The fully qualified class name of the metadata model.
     */
    'metadata_model' => Marshmallow\Models\Metadata::class,

    /*
     * The fully qualified class name of the metadata cast.
     */
    'metadata_cast' => Marshmallow\Casts\MetadataCast::class,
];

use Marshmallow\Metadata\Traits\HasMetadata;

use HasMetadata;


use Marshmallow\Metadata\Casts\MetadataCast;

protected $casts = [
    'example' => MetadataCast::class,
];

$example_model->example_field = 'This is an example';

$example_field = $example_model->example_field;
// 'This is an example'
bash
php artisan vendor:publish --tag="metadata-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="metadata-config"