zendframework/zend-expressive-twigrenderer
最新稳定版本:2.5.0
Composer 安装命令:
composer require zendframework/zend-expressive-twigrenderer
包简介
Twig integration for Expressive
README 文档
README
Repository abandoned 2019-12-31
This repository has moved to mezzio/mezzio-twigrenderer.
Provides Twig integration for Expressive.
Installation
Install this library using composer:
$ composer require zendframework/zend-expressive-twigrenderer
We recommend using a dependency injection container, and typehint against container-interop. We can recommend the following implementations:
- zend-servicemanager:
composer require zendframework/zend-servicemanager - pimple-interop:
composer require mouf/pimple-interop - Aura.Di:
composer require aura/di
Twig Extension
The included Twig extension adds support for url generation. The extension is automatically activated if the UrlHelper and ServerUrlHelper are registered with the container.
-
path: Render the relative path for a given route and parameters. If there is no route, it returns the current path.{{ path('article_show', {'id': '3'}) }} Generates: /article/3pathsupports optional query parameters and a fragment identifier.{{ path('article_show', {'id': '3'}, {'foo': 'bar'}, 'fragment') }} Generates: /article/3?foo=bar#fragmentBy default the current route result is used where applicable. To disable this the
reuse_result_paramsoption can be set.{{ path('article_show', {}, {}, null, {'reuse_result_params': false}) }} -
url: Render the absolute url for a given route and parameters. If there is no route, it returns the current url.{{ url('article_show', {'slug': 'article.slug'}) }} Generates: http://example.com/article/article.slugurlalso supports query parameters and a fragment identifier.{{ url('article_show', {'id': '3'}, {'foo': 'bar'}, 'fragment') }} Generates: http://example.com/article/3?foo=bar#fragmentBy default the current route result is used where applicable. To disable this the
reuse_result_paramsoption can be set.{{ url('article_show', {}, {}, null, {'reuse_result_params': false}) }} -
absolute_url: Render the absolute url from a given path. If the path is empty, it returns the current url.{{ absolute_url('path/to/something') }} Generates: http://example.com/path/to/something -
assetRender an (optionally versioned) asset url.{{ asset('path/to/asset/name.ext', version=3) }} Generates: path/to/asset/name.ext?v=3To get the absolute url for an asset:
{{ absolute_url(asset('path/to/asset/name.ext', version=3)) }} Generates: http://example.com/path/to/asset/name.ext?v=3
Configuration
If you use the zend-component-installer the factories are configured automatically for you when requiring this package with composer. Without the component installer, you need to include the ConfigProvider in your config/config.php. Optional configuration can be stored in config/autoload/templates.global.php.
'templates' => [ 'extension' => 'file extension used by templates; defaults to html.twig', 'paths' => [ // namespace / path pairs // // Numeric namespaces imply the default/main namespace. Paths may be // strings or arrays of string paths to associate with the namespace. ], ], 'twig' => [ 'cache_dir' => 'path to cached templates', 'assets_url' => 'base URL for assets', 'assets_version' => 'base version for assets', 'extensions' => [ // extension service names or instances ], 'runtime_loaders' => [ // runtime loaders names or instances ], 'globals' => [ // Global variables passed to twig templates 'ga_tracking' => 'UA-XXXXX-X' ], 'timezone' => 'default timezone identifier, e.g.: America/New_York', 'optimizations' => -1, // -1: Enable all (default), 0: disable optimizations 'autoescape' => 'html', // Auto-escaping strategy [html|js|css|url|false] 'auto_reload' => true, // Recompile the template whenever the source code changes 'debug' => true, // When set to true, the generated templates have a toString() method 'strict_variables' => true, // When set to true, twig throws an exception on invalid variables ],
Documentation
See the Expressive Twig documentation.
zendframework/zend-expressive-twigrenderer 适用场景与选型建议
zendframework/zend-expressive-twigrenderer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 353.23k 次下载、GitHub Stars 达 26, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「twig」 「ZendFramework」 「middleware」 「zf」 「psr」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zendframework/zend-expressive-twigrenderer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zendframework/zend-expressive-twigrenderer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zendframework/zend-expressive-twigrenderer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
repository php library
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
A Twig extension to insert css as inline styles with a tag
Caching and compression for Twig assets (JavaScript and CSS).
Twig extensions for Tracy Debugger
统计信息
- 总下载量: 353.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 26
- 点击次数: 19
- 依赖项目数: 17
- 推荐数: 1
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2026-01-04