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.
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
- Source documentation
- GitHub page with API documentation
- Issues tracker
- Packagist package
- Chillout Development @ GitHub
- Chillout Development @ Facebook
- Post on Wrzasq.pl
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:
chilldev/view-helpers-bundle 适用场景与选型建议
chilldev/view-helpers-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.65k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2012 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「templating」 「php」 「Symfony2」 「paginator」 「markup」 「xhtml」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 chilldev/view-helpers-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chilldev/view-helpers-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 chilldev/view-helpers-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
A Processor for Markup written in PHP. Allows extraction of Markup into a data structure, orchestrated nested manipulation of said structure, and output as (optimized) Markup.
Symfony2 Barcode Generator Bundle with Twig function extension
Symfony bundle to connect AWS sns and sqs to create offline queue processing
Integrate the doctrine-translatable extension in Symfony2
Video Editor Bundle
统计信息
- 总下载量: 1.65k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 17
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-11-07