1. Go to this page and download the library: Download isometriks/json-ld-dumper 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/ */
isometriks / json-ld-dumper example snippets
use Isometriks\JsonLdDumper\Dumper;
use Isometriks\JsonLdDumper\MappingConfiguration;
use Isometriks\JsonLdDumper\Parser;
use Isometriks\JsonLdDumper\Replacer\DateReplacer;
use Isometriks\JsonLdDumper\Replacer\ExpressionReplacer;
use Isometriks\JsonLdDumper\Replacer\ResourceReplacer;
use Isometriks\JsonLdDumper\Replacer\StaticReplacer;
use Isometriks\JsonLdDumper\Test\Model\AuthorInterface;
use Isometriks\JsonLdDumper\Test\Model\Image;
use Isometriks\JsonLdDumper\Test\Model\NewsArticle;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
rce.headline',
'image' => '$resource.image',
'publisher' => '$static.company',
'datePublished' => '$resource.published',
'author' => '$resource.author',
],
Image::class => [
'@context' => 'http://schema.org/',
'@type' => 'ImageObject',
'url' => '$resource.url',
'width' => '$resource.width',
'height' => '$resource.height',
],
AuthorInterface::class => [
'@context' => 'http://schema.org/',
'@type' => 'Person',
'name' => 'expr:"Mr. " ~ context.getName()',
],
];
$mapping = new MappingConfiguration($static, $entities);
$expressionLanguage = new ExpressionLanguage();
$parser = new Parser($mapping, [
new StaticReplacer($mapping),
new ResourceReplacer(),
new DateReplacer(),
new ExpressionReplacer($expressionLanguage),
]);
$dumper = new Dumper($parser);
echo $dumper->dump([
new NewsArticle(),
'$static.company',
]);
class FakeModel
{
public $var = '$static.company';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.