mezzio/mezzio-twigrenderer
Composer 安装命令:
composer require mezzio/mezzio-twigrenderer
包简介
Twig integration for Mezzio
README 文档
README
🇷🇺 Русским гражданам
Мы, участники Laminas, родились и живем в разных странах. У многих из нас есть друзья, родственники и коллеги как в России, так и в Украине. Некоторые из нас родились в России. Некоторые из нас живут в России. У некоторых бабушки и дедушки сражались с фашистами во Второй мировой войне. Здесь никто не поддерживает фашизм.
У одного из нас есть украинская родственница, которая спаслась из дома вместе с сыном. Поезд задержался из-за бомбежки на дороге впереди. У нас есть друзья, которые прячутся в бомбоубежищах. Мы с тревогой ждем весточки от них после воздушных налетов, которые беспорядочно наносят удары и попадают по больницам, школам, детским садам и домам. Мы не берем это из каких-либо СМИ. Мы наблюдаем это напрямую.
Вы доверяете нам достаточно, чтоб использовать наши программы, и мы просим вас довериться нам вновь. Мы нуждаемся в помощи. Выходите и протестуйте против этой бесполезной войны. Остановите кровопролитие. Скажите "Нет войне!"
🇺🇸 To Citizens of Russia
We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism.
One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences.
You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!"
Provides Twig integration for Mezzio.
Installation
Install this library using composer:
$ composer require mezzio/mezzio-twigrenderer
We recommend using a dependency injection container, and typehint against container-interop. We can recommend the following implementations:
- laminas-servicemanager:
composer require laminas/laminas-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 laminas-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 Mezzio Twig documentation.
mezzio/mezzio-twigrenderer 适用场景与选型建议
mezzio/mezzio-twigrenderer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 543.96k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2019 年 12 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「twig」 「middleware」 「psr」 「psr-7」 「laminas」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mezzio/mezzio-twigrenderer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mezzio/mezzio-twigrenderer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mezzio/mezzio-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
统计信息
- 总下载量: 543.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 23
- 依赖项目数: 17
- 推荐数: 5
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2019-12-31