{"id":19756813,"url":"https://github.com/imiphp/imi-smarty","last_synced_at":"2025-07-15T23:36:32.613Z","repository":{"id":52214576,"uuid":"201700866","full_name":"imiphp/imi-smarty","owner":"imiphp","description":"支持在 imi 框架中使用 Smarty 模版引擎。QQ群：17916227","archived":false,"fork":false,"pushed_at":"2024-01-19T02:17:20.000Z","size":205,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"2.0","last_synced_at":"2025-06-30T12:45:35.235Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.imiphp.com/","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imiphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-08-11T01:10:53.000Z","updated_at":"2022-01-05T01:13:40.000Z","dependencies_parsed_at":"2023-01-30T17:45:26.419Z","dependency_job_id":"74745587-ee9a-4152-bd7a-61a7bed17971","html_url":"https://github.com/imiphp/imi-smarty","commit_stats":{"total_commits":28,"total_committers":1,"mean_commits":28.0,"dds":0.0,"last_synced_commit":"95e76268c099dce257f561342ad0ab1db1317c27"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/imiphp/imi-smarty","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-smarty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-smarty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-smarty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-smarty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imiphp","download_url":"https://codeload.github.com/imiphp/imi-smarty/tar.gz/refs/heads/2.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-smarty/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265467615,"owners_count":23770752,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T03:17:01.464Z","updated_at":"2025-07-15T23:36:32.593Z","avatar_url":"https://github.com/imiphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# imi-smarty\n\n[![Latest Version](https://img.shields.io/packagist/v/imiphp/imi-smarty.svg)](https://packagist.org/packages/imiphp/imi-smarty)\n[![Php Version](https://img.shields.io/badge/php-%3E=7.4-brightgreen.svg)](https://secure.php.net/)\n[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.7.0-brightgreen.svg)](https://github.com/swoole/swoole-src)\n[![IMI License](https://img.shields.io/github/license/imiphp/imi-smarty.svg)](https://github.com/imiphp/imi-smarty/blob/master/LICENSE)\n\n## 介绍\n\n支持在 imi 框架中使用 Smarty 模版引擎\n\n\u003e 本仓库仅用于浏览，不接受 issue 和 Pull Requests，请前往：\u003chttps://github.com/imiphp/imi\u003e\n\n## Composer\n\n本项目可以使用composer安装，遵循psr-4自动加载规则，在你的 `composer.json` 中加入下面的内容:\n\n```json\n{\n    \"require\": {\n        \"imiphp/imi-smarty\": \"~2.0.0\"\n    }\n}\n```\n\n然后执行 `composer update` 安装。\n\n## 基本使用\n\n在项目 `config/config.php` 中配置：\n\n```php\n[\n    'components'    =\u003e  [\n        // 引入本组件\n        'Smarty'       =\u003e  'Imi\\Smarty',\n    ],\n]\n```\n\n在服务器的 `config/config.php` 中配置：\n\n```php\n[\n    'beans'    =\u003e    [\n        'HtmlView'    =\u003e    [\n            'templatePath'      =\u003e  dirname(__DIR__) . '/template/',\n            'templateEngine'    =\u003e  'SmartyEngine',\n            // 支持的模版文件扩展名，优先级按先后顺序\n            'fileSuffixs'        =\u003e    [\n                'tpl',\n                'html',\n                'php'\n            ],\n        ],\n        // 可选项\n        'SmartyEngine' =\u003e [\n            // 缓存目录\n            'cacheDir'      =\u003e  null,\n            // 编译目录\n            'compileDir'    =\u003e  null,\n            // 是否开启缓存，默认不开启\n            'caching'       =\u003e  0,\n            // 缓存有效时间\n            'cacheLifetime' =\u003e  0,\n        ],\n    ],\n];\n```\n\n## 进阶使用\n\n本组件没有封装大量的配置项，所以当你需要做一些其它设置时，可以监听 `IMI.SMARTY.NEW` 事件，当首次实例化对象时，触发该事件。\n\n事件参数数据如下：\n\n```php\n[\n    'smarty'        =\u003e  $smarty,        // Smarty 对象\n    'serverName'    =\u003e  $serverName,    // 当前服务器名\n]\n```\n\n## 免费技术支持\n\nQQ群：17916227 [![点击加群](https://pub.idqqimg.com/wpa/images/group.png \"点击加群\")](https://jq.qq.com/?_wv=1027\u0026k=5wXf4Zq)，如有问题会有人解答和修复。\n\n## 运行环境\n\n- [PHP](https://php.net/) \u003e= 7.4\n- [Composer](https://getcomposer.org/) \u003e= 2.0\n- [Swoole](https://www.swoole.com/) \u003e= 4.7.0\n\n## 版权信息\n\n`imi-smarty` 遵循 MIT 开源协议发布，并提供免费使用。\n\n## 捐赠\n\n\u003cimg src=\"https://cdn.jsdelivr.net/gh/imiphp/imi@2.0/res/pay.png\"/\u003e\n\n开源不求盈利，多少都是心意，生活不易，随缘随缘……\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimiphp%2Fimi-smarty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimiphp%2Fimi-smarty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimiphp%2Fimi-smarty/lists"}