extro/view-engine 问题修复 & 功能扩展

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

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

extro/view-engine

最新稳定版本:v1.0.0

Composer 安装命令:

composer require extro/view-engine

包简介

View engine

README 文档

README

Latest Version License

Extro View Engine

Lightweight template engine for PHP with inheritance support.

📦 Installation

composer require extro/view-engine

🚀 Quick Start

  1. Create a base template: resources/views/layout.php
<!DOCTYPE html>
<html>
<head><?= $this->section('head') ?></head>
<body>
    <?= $this->section() ?>
</body>
</html>
  1. Create a child template: resources/views/profile.php
<?php $this->extend('layout') ?>

<?php $this->start('head') ?>
    <title>My profile</title>
<?php $this->end() ?>

<h1>Hello, <?= $this->get('name') ?>!</h1>
  1. Render in your code
use Extro\ViewEngine\View;
use Extro\ViewEngine\ConfigInterface;

// Implement your config (e.g., path to views)
$config = new class implements ConfigInterface {
    public function getTemplateDir(): string {
        return __DIR__ . '/resources/views';
    }
};

$view = new View($config);
echo $view->render('profile', ['name' => 'John']);

📚 Documentation

Template Inheritance

<!-- base.php -->
<header><?= $this->section('header') ?></header>
<main><?= $this->section() ?></main>

<!-- page.php -->
<?php $this->extend('base') ?>

<?php $this->start('header') ?>
    Welcome Page
<?php $this->end() ?>

Main content goes here...

Data Handling

// Auto-escaped output (default)
<?= $this->get('user_content') ?>

// Raw HTML output (trusted content only)
<?= $this->get('trusted_html', true) ?>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-02