pedroborges/meta-tags
Composer 安装命令:
composer require pedroborges/meta-tags
包简介
HTML meta tags generator for PHP.
README 文档
README
HTML meta tags generator for PHP. Supports Open Graph, Twitter Cards, and JSON Linked Data out of the box.
Installation
composer require pedroborges/meta-tags
Basic Usage
Create a new MetaTags instance then you are ready to start adding meta tags:
use PedroBorges\MetaTags\MetaTags; $tags = new MetaTags; // <title>My Awesome Site</title> $tags->title('My Awesome Site'); // <meta name="description" content="My site description"> $tags->meta('description', 'My site description'); // <link rel="canonical" href="https://pedroborg.es"> // <link rel="alternate" hreflang="en" href="https://en.pedroborg.es"> $tags->link('canonical', 'https://pedroborg.es'); $tags->link('alternate', [ 'hreflang' => 'en', 'href' => 'https://en.pedroborg.es' ]); // <meta property="og:title" content="The Title"> // <meta property="og:type" content="website"> // <meta property="og:url" content="https://pedroborg.es"> // <meta property="og:image" content="https://pedroborg.es/cover.jpg"> $tags->og('title', 'The title'); $tags->og('type', 'website'); $tags->og('url', 'https://pedroborg.es'); $tags->og('image', 'https://pedroborg.es/cover.jpg'); // <meta name="twitter:card" content="summary"> // <meta name="twitter:site" content="@pedroborg_es"> $tags->twitter('card', 'summary'); $tags->twitter('site', '@pedroborg_es'); // <script type="application/ld+json"> // { // "@context": "http://schema.org", // "@type": "Person", // "name": "Pedro Borges" // } // </script> $tags->jsonld([ '@context' => 'http://schema.org', '@type': 'Person', 'name': 'Pedro Borges' ]);
When you are ready to output them, use the render method inside your template <head> element:
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php echo $tags->render() ?>
You can also render only one tag:
<?php echo $tags->render('title') ?>
Or specify which tags to render:
<?php echo $tags->render(['og', 'twitter', 'json-ld']) ?>
By default Meta Tag will indent the tags with 4 spaces and use the following order:
<title><meta>(General)<meta property="og:*">(Open Graph)<meta name="twitter:*">(Twitter Cards)<link><script type="application/ld+json">(JSON-LD)
You can change that when instantiating the MetaTag class:
use PedroBorges\MetaTags\MetaTags; $tags = new MetaTags("\t", ['meta', 'title', 'link', 'og', 'twitter', 'json-ld']);
Change Log
All notable changes to this project will be documented at: https://github.com/pedroborges/meta-tags/blob/master/changelog.md
License
Meta Tags is open-sourced software licensed under the MIT license.
Copyright © 2018 Pedro Borges oi@pedroborg.es
pedroborges/meta-tags 适用场景与选型建议
pedroborges/meta-tags 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28.82k 次下载、GitHub Stars 达 45, 最近一次更新时间为 2017 年 02 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「facebook」 「seo」 「open graph」 「meta」 「twitter cards」 「meta tags」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pedroborges/meta-tags 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pedroborges/meta-tags 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pedroborges/meta-tags 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Netgen Open Graph Bundle is an Ibexa Platform bundle that allows simple integration with Open Graph protocol.
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
Help to manage meta data on Laravel Eloquent model
A tool for scraping URL resources (oEmbed, OpenGraph, Twitter cards, JSON-LD)
Statamic Fine Seo addon
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
统计信息
- 总下载量: 28.82k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 46
- 点击次数: 23
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-02-28