PHP code example of vgirol / jsonapi-faker-laravel

1. Go to this page and download the library: Download vgirol/jsonapi-faker-laravel 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/ */

    

vgirol / jsonapi-faker-laravel example snippets


use VGirol\JsonApiFaker\Laravel\Generator as JsonApiFaker;

$faker = new JsonApiFaker;

$model = new DummyModel();
$factory = $faker->resourceObject($model, 'resourceType');

$factory->setMeta([
            'key1' => 'meta1'
        ])
        ->addLink('self', 'url');

$array = $factory->toArray();
$json = $factory->toJson();

use VGirol\JsonApiFaker\Generator as JsonApiFaker;

$model = new DummyModel();
$json = new JsonApiFaker()
    ->resourceObject($model, 'resourceType')
    ->setMeta([
            'key1' => 'meta1'
        ])
    ->toJson();