beyerz/open-graph-protocol-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

beyerz/open-graph-protocol-bundle

最新稳定版本:2.0.0

Composer 安装命令:

composer require beyerz/open-graph-protocol-bundle

包简介

Integration for OpenGraph protocol and Symfony2

README 文档

README

Packagist Minimum PHP Version Build Status

OpenGraphProtocolBundle

Easy Integration for Symfony2 projects requiring opengraph

The OpenGraphBundle enables easy integration for Symfony2 and twig views to incorporate the Open Graph Protocols

Important Note: If you are using symfony version less than 2.8, please stay with build v1.0 as v2.0 may not work correctly due to symfony using traits for container awareness

Installation

Composer

composer require beyerz/open-graph-protocol-bundle

Application Kernel

Add OpenGraphBundle to the registerBundles() method of your application kernel:

public function registerBundles()
{
    return array(
        new Beyerz\OpenGraphProtocolBundle\OpenGraphProtocolBundle(),
    );
}

Config

Enable loading of the OGP service and setting default values by adding the following to the application's config.yml file:

A Base and facebook library are currently supported, but you can add as many libraries with as many default values that you like

#OGP Bundle
open_graph_protocol:
    libraries:
        base:
            class: Beyerz\OpenGraphProtocolBundle\Libraries\Base
            default_values:
                site_name: {{ default value for website name }}
                type: {{ default value for website type }}
                title: {{ default value for any page title }}
                url: {{ default value for any canonical url (acts as a fall back for bad pages) }}
                image: {{ default image for your site }}
                description: {{ default generic page description for your site }}
        facebook:
            class: Beyerz\OpenGraphProtocolBundle\Libraries\Facebook
            default_values: { app_id: {{ Your apps facebook id }} }

Documentation

View

Include the OGP Metas in the head tag of your layout.

With twig:

{% block metas %}
        {{ ogp()|raw }}
{% endblock %}

Overriding Meta Values

Its common that you would want to change meta values like title, image, description etc... This is easily done from within your page page controller (or any where that has access to the service container)

From your Controller

$ogp = $this->get('beyerz.ogp.open_graph');
$base = $ogp->get('base');
$base->addMeta('title', "My dynamic title");
$base->addMeta('url', $request->getSchemeAndHttpHost().$request->getRequestUri());
$base->addMeta('description', "My dynamic description");

Testing Tools

Facebook

Twitter

统计信息

  • 总下载量: 6.48k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-10-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固