powerkernel/yii2-jsonld-helper
Composer 安装命令:
composer require powerkernel/yii2-jsonld-helper
包简介
JsonLD Helper class for Yii2
README 文档
README
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
{ "require": { "powerkernel/yii2-jsonld-helper": "*" } }
##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:
$doc = (object)[ "@type" => "http://schema.org/WebSite", "http://schema.org/name" => Yii::$app->params['brand'], "http://schema.org/url" => Yii::$app->urlManager->hostInfo ]; JsonLDHelper::add($doc);
You may pass $context as an optional second parameter if you need to use something other than default ["@vocab" => "http://schema.org/"]:
JsonLDHelper::add($doc, $context);
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:
JsonLDHelper::addBreadcrumbList();
Finally, you must invoke JsonLDHelper::registerScripts method in the <head> section of your layout, e.g.
<head> <!-- ... --> <?php JsonLDHelper::registerScripts(); ?> <?php $this->head() ?> </head>
###Example with nested data:
$doc = [ "@type" => "http://schema.org/BlogPosting", "http://schema.org/mainEntityOfPage" => (object)[ "@type" => "http://schema.org/WebPage", "@id" => "http://example.com/awesome-blog-post", ], "http://schema.org/headline" => "Post Title", "http://schema.org/articleBody" => "Post Body", "http://schema.org/author" => (object)[ "@type" => "http://schema.org/Person", "http://schema.org/name" => "Jon Snow", "http://schema.org/url" => "http://example.com", "http://schema.org/sameAs" => [ "https://www.instagram.com/kitharingtonn/", ] ], ]; JsonLDHelper::add($doc);
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.
powerkernel/yii2-jsonld-helper 适用场景与选型建议
powerkernel/yii2-jsonld-helper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.57k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「jsonld」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 powerkernel/yii2-jsonld-helper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 powerkernel/yii2-jsonld-helper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 powerkernel/yii2-jsonld-helper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
JSON-LD Processor for PHP
JSON-LD Processor for PHP
A PHP library that validates JSON-LD structured data against the schema.org vocabulary.
Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project
SCEditor, a lightweight WYSIWYG BBCode & HTML editor extension for Yii 2.0 Framework
统计信息
- 总下载量: 1.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-04-19