Download the PHP package powerkernel/yii2-jsonld-helper without Composer
On this page you can find all versions of the php package powerkernel/yii2-jsonld-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download powerkernel/yii2-jsonld-helper
More information about powerkernel/yii2-jsonld-helper
Files in powerkernel/yii2-jsonld-helper
Package yii2-jsonld-helper
Short Description JsonLD Helper class for Yii2
License MIT
Informations about the package yii2-jsonld-helper
yii2-jsonld-helper
Yii2 helper class for registering structured data markup in JSON-LD format.
Resources
- Yii2 extension page
- JSON-LD documentation
- Google Structured Data Testing Tool
Installation
Composer
Add extension to your composer.json
and update your dependencies as usual, e.g. by running composer update
Sample Usage
To let search engines know how to display your website name in search results, you can add the following JSON-LD document somewhere on your landing page:
You may pass $context
as an optional second parameter if you need to use something other than default ["@vocab" => "http://schema.org/"]
:
Note that doing so may cause resulting script to not pass validation by the Google's [SDTT] (https://search.google.com/structured-data/testing-tool) - refer this this stackoverflow question for details.
You can also use JsonLDHelper::addBreadcrumbList
to add BreadcrumbList
schema.org markup
based on the application view breadcrumbs
parameter. E.g. in the beginning of your layout add:
Finally, you must invoke JsonLDHelper::registerScripts
method in the <head>
section of your layout, e.g.
Example with nested data:
Note that this extension is just a thin wrapper around lanthaler/JsonLD processor - refer to this library for the full documentation.
License
Extension is released under MIT license.