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

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

lulanyin/smarty
===============

PHP Smarty模板引擎

0.9.1(5y ago)01201MITPHPPHP ^5.6 || ^7.0

Since Nov 24Pushed 4y ago1 watchersCompare

[ Source](https://github.com/lulanyin/inphp-smarty)[ Packagist](https://packagist.org/packages/lulanyin/smarty)[ RSS](/packages/lulanyin-smarty/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)DependenciesVersions (3)Used By (1)

smarty
======

[](#smarty)

#### 项目介绍

[](#项目介绍)

改过的Smarty模板引擎 可自定义标签

### 安装方法

[](#安装方法)

```
composer require inphp/smarty

```

### 使用方法

[](#使用方法)

```
//config.php
//在您的PHP入口配置文件中，定义常量，以声明您的自定义标签的文件夹位置：
define("SMARTY_TAGS_PARSER", ROOT."/smarty_tags");
//请在 SMARTY_TAGS_PARSER 文件夹中创建以下2个文件夹，文件夹名称必须一致：
//1. Compiler   ----    存放标签编译文件，请给予可写权限，因为编译时需要生成文件存放
//2. Tags       ----    您编写的自定义标签存放文件夹
```

### 自定义标签示例：

[](#自定义标签示例)

```
//文件命名规则 [标签名].tag.php
//函数命名规则 tag_[标签名]
//保存位置：SMARTY_TAGS_PARSER."/Tags"

//文件：SMARTY_TAGS_PARSER位置：ROOT."/smarty_tags/Tags/news_list.tag.php"
//新闻列表
function tag_news_list($params = []){
    //分类ID
    $category_id = $params['cid'] ?? 0;
    //查询获得列表 .... 过程请自行实现
    $list = [];
    //返回列表数据
    return $list;
}

//文件：SMARTY_TAGS_PARSER位置：ROOT."/smarty_tags/Tags/config.tag.php"
//获取配置字符串
function tag_config($params = []){
    //您设置了一个全局配置文件，大概值：
    $configs = [
        "email"    => "me@lanyin.lu",
        "url"      => "http://www.lanyin.lu"
    ];
    //参数字段
    $name = $params['name'] ?? null;
    if(!is_null($name)){
        return $configs[$name] ?? "";
    }
    return "";
}
```

### 模板中使用自定义标签，注意，下方设置的Smarty模板解析边缘字符串是 左边：{，右边：}

[](#模板中使用自定义标签注意下方设置的smarty模板解析边缘字符串是--左边右边)

```

    {news_list cid=5 item=n}

            {$n.title}
            {$n.description|truncate:30:'...':true}

    {news_liseelse}
    暂无新闻
    {/news_list}

我的邮箱是：{config name="email"}，欢迎访问我的博客：{config name="url"}。
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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 ~8 days

Total

2

Last Release

1986d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e7ba8f963b6d1a5d3ab8596777a2397367b19b013111e99f640e564045240178?d=identicon)[lanyin](/maintainers/lanyin)

---

Top Contributors

[![lulanyin](https://avatars.githubusercontent.com/u/5426155?v=4)](https://github.com/lulanyin "lulanyin (2 commits)")

---

Tags

phpsmarty

### Embed Badge

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

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

###  Alternatives

[endroid/qr-code-bundle

Endroid QR Code Bundle

32110.6M17](/packages/endroid-qr-code-bundle)[monotek/minitpl

Miniature fully featured PHP template engine

125.5k1](/packages/monotek-minitpl)

PHPackages © 2026

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