PHPackages                             imiphp/imi-smarty - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. imiphp/imi-smarty

ActiveLibrary[Templating &amp; Views](/categories/templating)

imiphp/imi-smarty
=================

支持在 imi 框架中使用 Smarty 模版引擎

v2.1.13(2y ago)341MulanPSL-2.0PHPCI failing

Since Aug 11Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/imiphp/imi-smarty)[ Packagist](https://packagist.org/packages/imiphp/imi-smarty)[ RSS](/packages/imiphp-imi-smarty/feed)WikiDiscussions 2.0 Synced 4d ago

READMEChangelog (8)Dependencies (2)Versions (29)Used By (0)

imi-smarty
==========

[](#imi-smarty)

[![Latest Version](https://camo.githubusercontent.com/9367175d623f8ad2cbf59ecd2f4e9f04c7c46090330f809a77cf2deebd9dd081/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d697068702f696d692d736d617274792e737667)](https://packagist.org/packages/imiphp/imi-smarty)[![Php Version](https://camo.githubusercontent.com/4a5c2ab20974058a8bab53ecb30ac4c2e6bb961df6229b7386fdc097ab53dfa8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d372e342d627269676874677265656e2e737667)](https://secure.php.net/)[![Swoole Version](https://camo.githubusercontent.com/f4210afc3f396a720a75802010218d847f3ba4f7ae5182c570b1fb2504ec9ec3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73776f6f6c652d2533453d342e372e302d627269676874677265656e2e737667)](https://github.com/swoole/swoole-src)[![IMI License](https://camo.githubusercontent.com/312285f8b10c05c1b34f6a5458951c35fcda359ae6e38c2627628c191b1504a6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f696d697068702f696d692d736d617274792e737667)](https://github.com/imiphp/imi-smarty/blob/master/LICENSE)

介绍
--

[](#介绍)

支持在 imi 框架中使用 Smarty 模版引擎

> 本仓库仅用于浏览，不接受 issue 和 Pull Requests，请前往：

Composer
--------

[](#composer)

本项目可以使用composer安装，遵循psr-4自动加载规则，在你的 `composer.json` 中加入下面的内容:

```
{
    "require": {
        "imiphp/imi-smarty": "~2.0.0"
    }
}
```

然后执行 `composer update` 安装。

基本使用
----

[](#基本使用)

在项目 `config/config.php` 中配置：

```
[
    'components'    =>  [
        // 引入本组件
        'Smarty'       =>  'Imi\Smarty',
    ],
]
```

在服务器的 `config/config.php` 中配置：

```
[
    'beans'    =>    [
        'HtmlView'    =>    [
            'templatePath'      =>  dirname(__DIR__) . '/template/',
            'templateEngine'    =>  'SmartyEngine',
            // 支持的模版文件扩展名，优先级按先后顺序
            'fileSuffixs'        =>    [
                'tpl',
                'html',
                'php'
            ],
        ],
        // 可选项
        'SmartyEngine' => [
            // 缓存目录
            'cacheDir'      =>  null,
            // 编译目录
            'compileDir'    =>  null,
            // 是否开启缓存，默认不开启
            'caching'       =>  0,
            // 缓存有效时间
            'cacheLifetime' =>  0,
        ],
    ],
];
```

进阶使用
----

[](#进阶使用)

本组件没有封装大量的配置项，所以当你需要做一些其它设置时，可以监听 `IMI.SMARTY.NEW` 事件，当首次实例化对象时，触发该事件。

事件参数数据如下：

```
[
    'smarty'        =>  $smarty,        // Smarty 对象
    'serverName'    =>  $serverName,    // 当前服务器名
]
```

免费技术支持
------

[](#免费技术支持)

QQ群：17916227 [![点击加群](https://camo.githubusercontent.com/75b53e353bb9e5064662e185a6d39f4bb88c4e45bd3a1240ddf599525edb6afa/68747470733a2f2f7075622e69647171696d672e636f6d2f7770612f696d616765732f67726f75702e706e67 "点击加群")](https://jq.qq.com/?_wv=1027&k=5wXf4Zq)，如有问题会有人解答和修复。

运行环境
----

[](#运行环境)

- [PHP](https://php.net/) &gt;= 7.4
- [Composer](https://getcomposer.org/) &gt;= 2.0
- [Swoole](https://www.swoole.com/) &gt;= 4.7.0

版权信息
----

[](#版权信息)

`imi-smarty` 遵循 MIT 开源协议发布，并提供免费使用。

捐赠
--

[](#捐赠)

[![](https://camo.githubusercontent.com/d6289b746e049310225a52ee7d4f9aab71cf9df63a3341cb037e7ec09b31ea1f/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f696d697068702f696d6940322e302f7265732f7061792e706e67)](https://camo.githubusercontent.com/d6289b746e049310225a52ee7d4f9aab71cf9df63a3341cb037e7ec09b31ea1f/68747470733a2f2f63646e2e6a7364656c6976722e6e65742f67682f696d697068702f696d6940322e302f7265732f7061792e706e67)

开源不求盈利，多少都是心意，生活不易，随缘随缘……

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance55

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~84 days

Recently: every ~245 days

Total

29

Last Release

96d ago

Major Versions

v1.0.2 → v2.0.02021-08-20

v2.1.12 → 3.0.x-dev2024-01-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f917bb42280d114c53cebadc2942a13ee03abe14971089f88895e266d637169?d=identicon)[Yurunsoft](/maintainers/Yurunsoft)

---

Top Contributors

[![Yurunsoft](https://avatars.githubusercontent.com/u/20104656?v=4)](https://github.com/Yurunsoft "Yurunsoft (29 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/imiphp-imi-smarty/health.svg)

```
[![Health](https://phpackages.com/badges/imiphp-imi-smarty/health.svg)](https://phpackages.com/packages/imiphp-imi-smarty)
```

###  Alternatives

[modx/revolution

MODX Revolution is a Content Management System

1.4k9.1k12](/packages/modx-revolution)[ytake/laravel-smarty

Smarty template engine for Laravel and Lumen

87401.6k](/packages/ytake-laravel-smarty)[noiselabs/smarty-bundle

This Symfony bundle provides integration for the Smarty3 template engine.

53194.4k1](/packages/noiselabs-smarty-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
