zkwbbr/view 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zkwbbr/view

最新稳定版本:v1.2.1

Composer 安装命令:

composer require zkwbbr/view

包简介

Display template file inside a layout file using plain PHP

README 文档

README

Display template file inside a layout file using plain PHP

Install

Install via composer as zkwbbr/view

Sample Usage

Create a templates folder (e.g., myTemplates/)

Inside your templates folder, create a layout file (e.g., myLayout.php) and put the ff.

<html>
    <head>
    <title><?=$title></title>
    </head>
    <body>
        <?=$templateContent?>
    </body>
</html>

Inside your templates folder, create a view file (e.g., myView.php) and put the ff.

<h1><?=$heading?></h1>
<?=$body?>

In your PHP code (e.g., controller), put the ff.

<?php

use Zkwbbr\View;

$data = [
    'title' => 'My Title',
    'heading' => 'My Heading',
    'body' => 'My Body'
];

$view = (new View\View)
    ->setData($data)
    ->setLayoutFile('myLayout')
    ->setTemplateVar('templateContent')
    ->setTemplateDir(__DIR__ . '/myTemplates/')
    ->setTemplate('myView')
    ->setBacktraceIndex(0) // # of nested calls relative to render(); for auto-detecting template file (try 0 first then increment until you find it)
    ->setStripStringFromTemplateFile('foo') // optional, remove string from template file (e.g., if your controller is the basis for auto template detection e.g., UserControllerIndex, and your actual template file is UserIndex, use 'Controller' as value here)
    ->render(); // you can also use generatedView() to return the generated view instead of outputting it

Expected output

<html>
    <head>
    <title>My Title</title>
    </head>
    <body>
        <h1>My Heading</h1>
        My Body
    </body>
</html>

统计信息

  • 总下载量: 144
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2019-04-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固