lukman-ss/view 问题修复 & 功能扩展

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

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

lukman-ss/view

Composer 安装命令:

composer require lukman-ss/view

包简介

A lightweight PHP view renderer with file lookup, namespaced views, sections, layouts, partials, and escaping helpers.

README 文档

README

Lukman View Hero Image

A lightweight PHP view renderer with file lookup, namespaced views, layouts, sections, partials, and escaping helpers.

Requirements

  • PHP >= 8.2

Installation

composer require lukman-ss/view

Usage

use Lukman\View\FileViewFinder;
use Lukman\View\PhpEngine;
use Lukman\View\ViewFactory;

$finder = new FileViewFinder([__DIR__ . '/views']);
$engine = new PhpEngine();
$view = new ViewFactory($finder, $engine);

echo $view->render('home', ['name' => 'Lukman']);

views/home.php:

Hello, <?php echo $e($name); ?>

View Names

Dot notation maps to paths:

echo $view->render('pages.home');

This resolves views/pages/home.php.

Namespaced views:

$finder->addNamespace('admin', __DIR__ . '/views/admin');

echo $view->render('admin::dashboard.index');

Shared Data

$view->share('appName', 'Demo');
$view->share(['locale' => 'en']);

echo $view->render('home', ['appName' => 'Override']);

Render data overrides shared data.

Layouts and Sections

views/layouts/app.php:

<title><?php echo $section('title', 'Default'); ?></title>
<main><?php echo $section('content'); ?></main>

views/home.php:

<?php $extend('layouts.app'); ?>

<?php $start('title'); ?>Home<?php $end(); ?>

<?php $start('content'); ?>
Hello, <?php echo $e($name); ?>
<?php $end(); ?>

Partials

<?php echo $include('partials.card', ['title' => 'Profile']); ?>

Included views receive parent data. Additional include data overrides parent data.

Escaping

<?php echo $e($value); ?>
<?php echo $raw($html); ?>

$e() escapes with htmlspecialchars using ENT_QUOTES | ENT_SUBSTITUTE and UTF-8. $raw() returns unescaped string output.

Exceptions

  • Lukman\View\Exception\ViewNotFoundException
  • Lukman\View\Exception\ViewException

Running Tests

composer test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固