承接 pieceofcake2/twig-view 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

pieceofcake2/twig-view

最新稳定版本:v2.0.2

Composer 安装命令:

composer require pieceofcake2/twig-view

包简介

Twig for CakePHP 2.x

README 文档

README

GitHub License Packagist Version PHP CakePHP Twig CI Codecov

Modern Twig 3.x support for CakePHP 2.x with PSR-4 namespaces and PHP 8.1+.

This plugin integrates the Twig Templating Language with CakePHP 2, providing access to helpers, elements, and themes.

Note

For CakePHP 5.x, use the official cakephp/twig-view package instead.

Requirements

  • PHP 8.1+
  • CakePHP 2.12+
  • Twig 3.x

Installation

Install via Composer:

composer require pieceofcake2/twig-view

Load the plugin in your app/Config/bootstrap.php:

CakePlugin::load('TwigView');
// or
CakePlugin::loadAll();

Quick Start

Set the view class in your app/Controller/AppController.php:

class AppController extends Controller
{
    public $viewClass = 'TwigView.Twig';
}

Create templates with .twig extension:

{# app/View/Posts/index.twig #}
{% for post in posts %}
    <h2>{{ post.Post.title }}</h2>
    <p>{{ post.Post.body }}</p>
{% endfor %}

Documentation

Features

  • CakePHP Integration: Full access to helpers, elements, and themes
  • Custom Extensions: Extend Twig with custom filters and functions
  • Theme Support: Compatible with CakePHP's themed views
  • Plugin Support: Works with both View/ and templates/ directories
  • Pre-compilation: Compile templates for production performance
  • PSR-4 Namespaces: Modern PHP architecture

Fork History

This project is based on the following repositories:

  1. m3nt0r-legacy/cakephp-twig-view - Original implementation by Kjell Bublitz
  2. predominant/TwigView - Fork by Graham Weldon (archived in 2019) - Direct fork source
  3. cakephp/legacy-twig-view - CakePHP community version (formerly WyriHaximus/TwigView, deprecated)
  4. pieceofcake2/twig-view (this repository) - Modernized fork with Twig 3.x and PHP 8.1+ support

The original repositories supported Twig 1.x with CakePHP 2.x but are no longer maintained. This fork updates the codebase to work with modern PHP and Twig versions while maintaining CakePHP 2.x compatibility.

统计信息

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

GitHub 信息

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

其他信息

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