PHP code example of imiphp / imi-smarty

1. Go to this page and download the library: Download imiphp/imi-smarty library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

imiphp / imi-smarty example snippets


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

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

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