fignon/fignon-smarty-engine

Fignon smarty 引擎是一个简单的类,它充当 smarty 模板引擎和 Fignon 框架之间的桥梁。

0.0.1 2024-02-16 11:56 UTC

This package is auto-updated.

Last update: 2024-09-16 14:13:35 UTC


README

这是一个封装 Smarty 模板引擎并使其在 Fignon 框架中易于使用的简单类。

在您的 Fignon 项目中,运行

composer require fignon/fignon-smarty-engine

然后,可以这样使用它

//app.php (or index.php) depending of how you call you entry point
declare(strict_types=1);

include_once __DIR__ . "/../vendor/autoload.php";

use Fignon\Tunnel;
use App\Features\Features;
use Fignon\Extra\SmartyEngine;

$app = new Tunnel();
$app->set('env', 'development');
// ... other middlewares

// View engine initialization
$app->set('views', dirname(__DIR__) . '/templates');
$app->set('views cache', dirname(__DIR__) . '/var/cache');
$app->set('view engine options', [ // Smarty require these additional option to work
    'compileDir' => 'path/to/compile/dir',
    'configDir' => 'path/to/config/dir'
]); // Add options to the view engine
$app->engine('smarty', new SmartyEngine()); 

$app->set('case sensitive routing', true);
//  ... other middlewares
 

// You can then use it to render
(new Features($app))->bootstrap();

$app->listen();

Fignon 的其他视图引擎集成包括

Smarty 配置文件示例

#path/to/config/dir/smarty_config.conf

# global variables
pageTitle = "Main Menu"
bodyBgColor = #000000
tableBgColor = #000000
rowBgColor = #00ff00

[Customer]
pageTitle = "Customer Info"

[Login]
pageTitle = "Login"
focus = "username"
Intro = """This is a value that spans more
           than one line. you must enclose
           it in triple quotes."""

# hidden section
[.Database]
host=my.example.com
db=ADDRESSBOOK
user=php-user
pass=foobar

要了解更多关于 Smarty 的信息,请参阅 Smarty 文档。