floor12/yii2-metamaster
Composer 安装命令:
composer require floor12/yii2-metamaster
包简介
This Yii2 component helps to organize page title, meta tags and `og` and `twitter` open graph tags in with a fiew lines of code.
关键字:
README 文档
README
Этот файл так же доступен на русском языке.
This is a component for generate some Meta, Open Graph and Twitter-card tags in a template header of Yii2 app.
This is a list of supported tags:
- canonical
- head title
- meta description
- meta keywords
- og:sitename
- og:type
- og:url
- og:title
- og:description
- og:image
- og:image:width
- og:image:height
- twitter:card
- twitter:domain
- twitter:site
- twitter:description
- twitter:image:src
- itemprop:name
- itemprop:image
Installation
Just run:
$ composer require floor12/yii2-metamaster
or add this to the require section of your composer.json.
"floor12/yii2-metamaster": "dev-master"
After that, include some basic metamaster data into components section of application config.
'components' => [ 'metamaster' => [ 'class' => 'floor12\metamaster\MetaMaster', 'siteName' => 'My cool new Web Site', 'defaultImage' => '/design/export_logo.png', ], ...
Attributes:
siteName- name of project to show in Open Graph tags;defaultImage- web relative path to default image for Open Graph tags;web- yii2 alias to web path to read image width and height for Open Graph tags (default is@app/web)protocol- default protocol to generate links (default ishttps)
Usage
Its possible to use in any place of your app. Just use setters and then call the register(View $view) method with View object passed into it.
Allowed setters:
Metamaster::setSiteName(string $value) Metamaster::setTitle(string $value) Metamaster::setUrl(string $value) Metamaster::setType(string $value) Metamaster::setDescription(string $value) Metamaster::setImage(string $relativePath, string $absolutePath = null)
For example, using in controller:
public function actionIndex() { Yii::$app->metamaster ->setTitle("This is test page") ->setDescription("This is page description") ->setImage('/images/article/image.png') ->register(Yii::$app->getView()); return $this->render('index'); }
It will generate all you need in template:
<title>This is test page</title> <link href="https://your-domain.com/site/index" rel="canonical"> <meta name="description" content="This is page description"> <meta property="og:site_name" content="My cool new Web Site"> <meta property="og:type" content="article"> <meta property="og:url" content="https://your-domain.com/site/index"> <meta name="twitter:card" content="summary"> <meta name="twitter:domain" content="https://your-domain.com"> <meta name="twitter:site" content="My cool new Web Site"> <meta property="og:title" content="This is test page"> <meta itemprop="name" content="This is test page"> <meta property="og:description" content="This is page description"> <meta name="twitter:description" content="This is page description"> <meta property="og:image" content="https://your-domain.com/images/article/image.png"> <meta property="twitter:image:src" content="https://your-domain.com/images/article/image.png"> <meta itemprop="image" content="https://your-domain.com/images/article/image.png">
floor12/yii2-metamaster 适用场景与选型建议
floor12/yii2-metamaster 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.29k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2018 年 07 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「seo」 「opengraph」 「meta」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 floor12/yii2-metamaster 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 floor12/yii2-metamaster 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 floor12/yii2-metamaster 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple PHP Open Graph Protocol parser library
Harvest statistics and meta data from an URL or his source code (seo oriented).
Phalcon PHP Meta tags service
A SilverStripe module to optimise the Meta, crawling, indexing, and sharing of your website content (forked from Cyber-Duck/Silverstripe-SEO)
Improves silverstripes html meta data options.
Extracts information about medias on the web, like youtube videos, twitter statuses or blog articles.
统计信息
- 总下载量: 5.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 25
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-05