provision/meta-tags
Composer 安装命令:
composer require provision/meta-tags
包简介
A package to manage Header Meta Tags
关键字:
README 文档
README
With this package you can manage header Meta Tags from Laravel controllers.
Installation
From the command line run
$ composer require provision/meta-tags
Once Meta Tags is installed you need to register the service provider with the application. Open up config/app.php and find the providers key.
'providers' => array( ProVision\MetaTags\MetaTagsServiceProvider::class, )
Meta Tags also ships with a facade which provides the static syntax for creating collections. You can register the facade in the aliases key of your config/app.php file.
'aliases' => array( 'MetaTag' => ProVision\MetaTags\Facades\MetaTag::class, )
Publish the configurations
Run this on the command line from the root of your project:
$ php artisan vendor:publish --provider="ProVision\MetaTags\MetaTagsServiceProvider"
A configuration file will be publish to config/meta-tags.php.
Twitter Cards and OpenGraph
Various settings for these options can be found in the config/meta-tags.php file.
Twitter Cards
{!! MetaTag::twitterCard() !!}
OpenGraph
{!! MetaTag::openGraph() !!}
Examples
app/Http/Controllers/Controller.php
<?php namespace App\Http\Controllers; use Illuminate\Foundation\Bus\DispatchesCommands; use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use MetaTag; abstract class Controller extends BaseController { use DispatchesCommands, ValidatesRequests; public function __construct() { // Defaults MetaTag::set('description', 'Blog Wes Anderson bicycle rights, occupy Shoreditch gentrify keffiyeh.'); MetaTag::set('image', asset('images/default-share-image.png')); } }
app/Http/Controllers/HomeController.php
<?php namespace App\Http\Controllers; use MetaTag; class HomeController extends Controller { public function index() { // Section description MetaTag::set('title', 'You are at home'); MetaTag::set('description', 'This is my home. Enjoy!'); return view('index'); } public function detail() { // Section description MetaTag::set('title', 'This is a detail page'); MetaTag::set('description', 'All about this detail page'); MetaTag::set('image', asset('images/detail-logo.png')); return view('detail'); } public function private() { // Section description MetaTag::set('title', 'Private Area'); MetaTag::set('description', 'You shall not pass!'); MetaTag::set('image', asset('images/locked-logo.png')); return view('private'); } }
resources/views/layouts/app.blade.php
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ MetaTag::get('title') }}</title>
{!! MetaTag::tag('description') !!}
{!! MetaTag::tag('image') !!}
{!! MetaTag::openGraph() !!}
{!! MetaTag::twitterCard() !!}
{{--Set default share picture after custom section pictures--}}
{!! MetaTag::tag('image', asset('images/default-logo.png')) !!}
</head>
<body>
@yield('content')
</body>
</html>
provision/meta-tags 适用场景与选型建议
provision/meta-tags 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 2.7k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「tags」 「laravel」 「meta」 「meta tags」 「head」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 provision/meta-tags 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 provision/meta-tags 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 provision/meta-tags 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A powerfull cacher based on laravels file cache driver
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)
Help to manage meta data on Laravel Eloquent model
A simple, repeatable field type
统计信息
- 总下载量: 2.7k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-28