asanusi007/ci4-smarty
Composer 安装命令:
composer require asanusi007/ci4-smarty
包简介
Integrate smarty template engine to CodeIgniter 4 with easy way.
README 文档
README
Simple way to integrate Smarty template engine into Codeigniter 4
Installation
Use the package manager composer to install Smarty.
composer require asanusi007/ci4-smarty
Usage
Open BaseController.php inside app/Controllers/BaseController.php and add this code
use Asanusi007\Smarty\Traits\Viewable; /** * Class BaseController * * BaseController provides a convenient place for loading components * and performing functions that are needed by all your controllers. * Extend this class in any new controllers: * class Home extends BaseController * * For security be sure to declare any new methods as protected or private. */ abstract class BaseController extends Controller { use Viewable; .... }
And then, you can use it like this:
class Home extends BaseController { public function index() { $data['title'] = 'Home'; return $this->parse('home', $data); } }
Configuration
You can change the default configuration by copy a file named smarty.php in the Src/Config/ folder to app/Config/Smarty.php, then you can change the configuration as you want.
<?php declare(strict_types=1); namespace App\Config; use CodeIgniter\Config\BaseConfig; class Smarty extends BaseConfig { // Smarty caching enabled by default unless explicitly set to FALSE public $cache_status = false; // Cache lifetime. Default value is 3600 seconds (1 hour) Smarty's default value public $cache_lifetime = -1; // Where templates are compiled public $compile_directory = WRITEPATH . 'cache/smarty/compiled/'; // Where templates are cached public $cache_directory = WRITEPATH . 'cache/smarty/cached/'; // Where Smarty configs are located public $config_directory = APPPATH . 'third_party/Smarty/configs/'; // Where Smarty views are located public $template_directory = [ APPPATH . 'Views/', APPPATH . 'Views/admin/', APPPATH . 'Views/website/', ]; // Default extension of templates if one isn't supplied public $template_ext = 'tpl'; // Error reporting level to use while processing templates public $template_error_reporting = E_ALL & ~E_NOTICE; // Debug mode turned on or off (TRUE / FALSE) public $smarty_debug = false; public $smarty_modifiers = []; }
Template Folder
By default, the template folder is app/Views/ and the template file extension is .tpl.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
for futher information, you can visit Smarty Documentation
License
asanusi007/ci4-smarty 适用场景与选型建议
asanusi007/ci4-smarty 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「template」 「smarty」 「codeigniter」 「codeigniter4」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 asanusi007/ci4-smarty 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 asanusi007/ci4-smarty 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 asanusi007/ci4-smarty 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Rewritten Smarty foreach variant that was invented for use in xoops, but nowadays is used in some other PHP based CMS'es
The CodeIgniter Redis package
Modified Smarty for Rudrax
Modified Smarty for Rudrax
redbeanphp service for Rudrax
统计信息
- 总下载量: 31
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-10