定制 chilldev/view-helpers-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

chilldev/view-helpers-bundle

最新稳定版本:0.1.9

Composer 安装命令:

composer require chilldev/view-helpers-bundle

包简介

General-purpose view helpers for PHP templating engine from Chillout Development.

README 文档

README

ChillDevViewHelpersBundle is a Symfony2 bundle that brings set of useful view helpers for PHP templating engine.

Build Status Scrutinizer Quality Score Coverage Status Dependency Status SensioLabsInsight

Because not everyone uses Twig…

Installation

This bundle is provided as Composer package. To install it simply add following dependency definition to your composer.json file:

"chilldev/view-helpers-bundle": "dev-master"

Replace dev-master with different constraint if you want to use specific version.

Note: This bundle requires PHP 5.4.

Configuration

All you need to do in order to use this bundle's goods is to load it in your kernel:

<?php

use ChillDev\Bundle\ViewHelpersBundle\ChillDevViewHelpersBundle;

use Symfony\Component\HttpKernel\Kernel as BaseKernel;

class Kernel extends BaseKernel
{
    public function registerBundles()
    {
        $bundles = [
            new ChillDevViewHelpersBundle(),
        ];
    }
}

Of course there are some optional configuration options.

Usage

Major feature of this bundle is set of common (X)HTML tag helpers like <meta>, <link> etc. Here is sample usage:

In your view file:

<?php $view->extend('::layout.html.php'); ?>

<?php $view['title']->append($page->getName()); ?>
<?php $view['meta']->getMetaName('keywords')->append($page->getKeywords()); ?>
<?php $view['meta']->setMetaName('description', \strip_tags($page->getDescription())); ?>
<?php $view['meta']->setProperty('og:title', $page->getName()); ?>
<?php $view['link']->add('http://example.com/page-2-slug.html', 'next'); ?>
<?php $view['script']->add('/javascript/prototype.js'); ?>
<?php $view['xmlns']['http://www.w3.org/1999/xhtml'] = ''; ?>
<?php $view['xmlns']['http://purl.org/NET/hinclude'] = 'hx'; ?>
<?php $view['xmlns']['http://ogp.me/ns#'] = 'og'; ?>
<?php $view['xmlns']['http://ogp.me/ns/fb#'] = 'fb'; ?>

<p><?php echo $view['truncate']->truncate($text, 255); ?></p>

In your layout file:

<!DOCTYPE html>
<html<?php echo $view['xmlns']; ?>>
    <head>
        <?php echo $view['title']; ?>
        <?php echo $view['meta']; ?>
        <?php echo $view['link']; ?>
        <?php echo $view['script']; ?>
    </head>
    <body>
        <?php $view['slots']->output('_content') ?>
    </body>
</html>

For more advanced aspects see advanced usage documentation or even internals description.

Extras

There are also some extra resources included in this bundle that can be useful for your PHP-templates-based project.

KnpPaginatorBundle supports PHP templating, but lacks default template for paginator helper. You can use one from this bundle with just following one setting in your application configuration:

# KNP paginator configuration
knp_paginator:
    template:
        pagination: "ChillDevViewHelpersBundle:Pagination:sliding.html.php"

Another additional enchantment to PHP templating engine provided by this bundle is possibility to define global templating variables. This feature is available out of the box for Twig templating engine in Symfony (with TwigBundle), but there is no equivalent for native PHP templates. Now, with our bundle you can do:

chilldev_viewheleprs:
    globals:
        values:
            slogan: "The best page ever!"
        services:
            sms: "your.sms.service"

And use it directly in templates:

<h1><?php echo $slogan; ?></h1>
<p><?php echo $sms->getGatewayNumber(); ?></p>

Resources

Contributing

Do you want to help improving this project? Simply fork it and post a pull request. You can do everything on your own, you don't need to ask if you can, just do all the awesome things you want!

This project is published under MIT license.

Authors

ChillDevViewHelpersBundle is brought to you by Chillout Development.

List of contributors:

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-11-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固