PHPackages                             ymj666/think-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. ymj666/think-smarty

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

ymj666/think-smarty
===================

Smarty Template driver for ThinkPHP6/ThinkPHP8

1.0.0(1y ago)022MITPHPPHP ^8.0

Since Jul 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ymj666/think-smarty)[ Packagist](https://packagist.org/packages/ymj666/think-smarty)[ Docs](https://github.com/ymj666/think-smarty)[ RSS](/packages/ymj666-think-smarty/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

think-smarty
============

[](#think-smarty)

ThinkPHP6/ThinkPHP8 Smarty 模板引擎驱动，使用 Smarty5 作为模板引擎

安装
--

[](#安装)

```
composer require ymj666/think-smarty
```

配置
--

[](#配置)

配置文件沿用了 ThinkPHP 的 `view.php` 配置文件，要使用 think-smarty 请先将 `view.php` 中的 `type` 配置项修改为 `ThinkSmarty::class`

增加和修改了几个配置项：

- `tpl_cache`: 是否开启模板编译缓存，设为 `false` 则每次都会重新编译，默认为 `true`
- `tpl_cache_path`: 模板编译缓存目录，对应 Smarty 的 `CompileDir` 配置，默认为 `runtime/temp`
- `display_cache`: 是否开启模板渲染缓存，设置为 `true` 则缓存过期前会直接读取渲染结果输出，默认为 `false`
- `display_cache_path`: 模板渲染缓存目录，对应 Smarty 的 `CacheDir` 配置，默认为 `runtime/display_cache`
- `display_cache_time`: 模板渲染缓存有效期，单位：秒。设置为 `0` 则永不过期，默认为 `3600`
- `tpl_replace_string`: 模板输出替换，是一个数组，格式为 `'原文本' => '替换的文本'`，如：`'__STATIC__'  => '/static'`

更多配置项，请查看 `ThinkSmarty.php`

使用
--

[](#使用)

在 Smarty 模板文件中可以直接使用 ThinkPHP 的部分助手函数，具体可查看 `ThinkSmarty.php`

- `cache`
- `config`
- `cookie`
- `env`
- `input`
- `lang`
- `parse_name`
- `session`
- `token`
- `token_field`
- `token_meta`
- `url`
- `app_path`
- `base_path`
- `config_path`
- `public_path`
- `runtime_path`
- `root_path`

相关链接
----

[](#相关链接)

- [ThinkPHP8 文档](https://doc.thinkphp.cn/v8_0)
- [Smarty 文档](https://smarty-php.github.io/smarty/)

其他说明
----

[](#其他说明)

代码参考了 ThinkPHP8 内置的 PHP 模板引擎

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

675d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/46645b9ab5d1a7d32f918a22590c0863ecb22ecfc921ab7653d49835e468f3fc?d=identicon)[ymj666](/maintainers/ymj666)

---

Top Contributors

[![ymj666](https://avatars.githubusercontent.com/u/45595375?v=4)](https://github.com/ymj666 "ymj666 (1 commits)")

---

Tags

smartythinkphpthink-smarty

### Embed Badge

![Health badge](/badges/ymj666-think-smarty/health.svg)

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

###  Alternatives

[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)[latrell/smarty

This package lets you run Smarty3 on Laravel5 elegantly.

127.0k](/packages/latrell-smarty)[nhzex/think-blade

Use Laravel Blade templates without the full Laravel framework

112.7k](/packages/nhzex-think-blade)

PHPackages © 2026

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