Php 如何检测smarty模板框架的使用?
除了存在Smarty.class.php(这也是有争议的),我们如何通过查看其文件结构就知道php项目正在使用Smarty模板框架?我认为您可以通过检查基本视图类来了解它Php 如何检测smarty模板框架的使用?,php,smarty,Php,Smarty,除了存在Smarty.class.php(这也是有争议的),我们如何通过查看其文件结构就知道php项目正在使用Smarty模板框架?我认为您可以通过检查基本视图类来了解它 class View { protected $tpl; protected $tplfilename; public function __construct() { $this->tpl = new Smarty(); $this->tpl-&
class View
{
protected $tpl;
protected $tplfilename;
public function __construct()
{
$this->tpl = new Smarty();
$this->tpl->template_dir = dirname(__FILE__)."/templates";
$this->tpl->compile_dir = dirname(__FILE__)."/templates_c";
$this->tpl->config_dir = dirname(__FILE__)."/configs";
$this->tpl->cache_dir = dirname(__FILE__)."/cache";
$this->tpl->left_delimiter = "{|";
$this->tpl->right_delimiter = "|}";
$this->tplfilename = "default.tpl";
}
public function show()
{
$this->tpl->display($this->tplfilename);
}
}
这可能是一种典型的smarty风格 我认为您可以通过检查基本视图类来了解它
class View
{
protected $tpl;
protected $tplfilename;
public function __construct()
{
$this->tpl = new Smarty();
$this->tpl->template_dir = dirname(__FILE__)."/templates";
$this->tpl->compile_dir = dirname(__FILE__)."/templates_c";
$this->tpl->config_dir = dirname(__FILE__)."/configs";
$this->tpl->cache_dir = dirname(__FILE__)."/cache";
$this->tpl->left_delimiter = "{|";
$this->tpl->right_delimiter = "|}";
$this->tplfilename = "default.tpl";
}
public function show()
{
$this->tpl->display($this->tplfilename);
}
}
这可能是一种典型的smarty风格 通常,结构良好的项目会有一个模板和模板文件夹-尽管名称可以配置/更改。另外,在这些文件夹中查找.tpl文件
我能看到的最好的方法是grep常见的smarty函数,比如fetch/assign/display,或者常见的smarty标记,比如{foreach}、{assign}、{if},等等。通常结构良好的项目会有一个模板和模板文件夹,尽管名称可以配置/更改。另外,在这些文件夹中查找.tpl文件
我能看到的最好的方法是grep常见的smarty函数,比如fetch/assign/display,或者常见的smarty标记,比如{foreach}、{assign}、{if},等等。你可能需要到处寻找模板和模板,在我的一个项目中,它们甚至不在htdocs中,smarty文件夹与htdocs处于同一级别。我们根据这个项目命名了Smarty类,所以即使是寻找“new Smarty()”也不起作用
我认为第一个建议您寻找常见smarty功能的答案可能是您的最佳选择。您可能需要四处寻找模板和模板\u c-在我的一个项目中,它们甚至不在htdocs中-smarty文件夹与htdocs处于同一级别。我们根据这个项目命名了Smarty类,所以即使是寻找“new Smarty()”也不起作用
我认为第一个建议您寻找常见smarty功能的答案可能是您的最佳选择。并非所有项目都基于OOP或使用MVC方法。虽然我认为如果他们这样做会更好;)@pinaki True,则很难知道这一点,因为smarty中的大多数目录都是可配置的。由于需要编译目录,因此可以查找以下两种情况之一:存在默认的“templates_c”文件夹或包含“->compile_dir”的行。并非所有项目都基于OOP或使用MVC方法。虽然我认为如果他们这样做会更好;)@pinaki True,则很难知道这一点,因为smarty中的大多数目录都是可配置的。由于需要编译目录,因此可以查找以下两种情况之一:存在默认的“templates_c”文件夹或包含“->compile_dir”的行。