maslosoft/miniview 问题修复 & 功能扩展

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

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

maslosoft/miniview

最新稳定版本:2.0.4

Composer 安装命令:

composer require maslosoft/miniview

包简介

Mini view is minimal template rendering library with pluggable template engines. Out of the box it support plain PHP templates, Latte and Twig.

README 文档

README

Miniview Logo Maslosoft Miniview

Mini view is minimal template rendering library with pluggable template engines. Out of the box it support plain PHP templates, Latte and Twig.

Latest Stable Version License Scrutinizer Code Quality Code Coverage

Quick Install

composer require maslosoft/miniview

Documentation

Full Miniview Documentation

Minimal PHP view

PHP itself is a kind of templating language. Some other supplemental languages have been implemented too. To use each one of them, we need to know how to use it, locate file exacly, and use some low-level commands like require.

Common interface

This view library provides common interface for PHP, or other templating engines, with option to extend it. Main power of miniview, is that it requires minimum code and effort to use MVC like views. It will also locate file relativelly to currently used class. It is safe to use with any functions directly outputting text, as it will capture any output and allow it to be passed anywhere, or just be displayed.

Usage

This is some example widget using MiniView:

namespace Company\SomeNamespace;

use Maslosoft\MiniView\MiniView;

class MyWidget
{

	/**
	 * View renderer
	 * @var MiniView
	 */
	public $view = null;
	
	/**
	 * @var string
	 */
	public $version = '';

	public function __construct()
	{
		$this->view = new MiniView($this);
		$this->version = $this->view->getVersion();
	}

	public function show()
	{
		return $this->view->render('myView', ['user' => 'Joe'], true);
	}

	public function greet($name)
	{
		return "Nice to meet you $name!" . PHP_EOL;
	}
}

In view file, all widget public properties as well as methods are available using $this. View file is located in folder views located in same folder as widget class.

Example view file:

Hello <?= $user ?>!
<?= $this->greet($user);?>
The version is <?= $this->version;?>

Calling show() will return rendered view file located in classFolder/views/myView.php with variable $user with value Joe.

use Company\SomeNamespace\MyWidget;

require __DIR__ . '/../src/Miniview.php';
require __DIR__ . '/MyWidget.phps';

$widget = new MyWidget;

echo $widget->show();

Run example

Go to examples folder and type php run.php

统计信息

  • 总下载量: 4.24k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 5
  • 推荐数: 1

GitHub 信息

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

其他信息

  • 授权协议: AGPL
  • 更新时间: 2014-12-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固