dtkahl/php-simple-view

1.5.0 2016-09-04 06:17 UTC

This package is auto-updated.

Last update: 2024-08-29 04:03:30 UTC


README

Latest Stable Version License Build Status

PHP简单视图

简单的PHP视图渲染器。

依赖关系

  • PHP >= 5.6.0

安装

使用 Composer 安装

composer require dtkahl/php-simple-view

用法

在PHP的任何地方

$renderer = new \Dtkahl\SimpleView\ViewRenderer(__DIR__.'/views/');
echo $render->render('example.php', ['name' => 'test']);

/views/example.php

<!DOCTYPE html>
<html>
  <head></head>
  <body><?php echo $name ?></body>
<html>

方法

addViewPaths($paths)

添加render应该搜索视图文件的位置。返回渲染器实例。

####render(string $file, array $data = []) 使用给定的数据(作为局部变量)渲染给定的视图文件。