定制 devuri/twigit 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

devuri/twigit

Composer 安装命令:

composer require devuri/twigit

包简介

Twig integration library

README 文档

README

A Streamlined Templating Approach

Modern development increasingly leans toward mono repo architectures that centralize application code, dependencies, and templates in a unified repository. This approach simplifies collaboration, version control, and deployment—making it ideal for large-scale and maintainable web projects.

Embrace the Hybrid CMS:

A hybrid-cms approach allows you to keep WordPress’ as your back end while bypassing the default theme system in favor of a templating engine like Twig.

1. Install Twigit via Composer

In your project root (mysite), install Twigit using Composer:

composer require devuri/twigit

This installs Twigit and Twig in the vendor directory.

2. Configure Twigit to Use the templates Directory

Twigit can be configured via an mu-plugin or programmatically to locate templates in mysite/templates. For example:

// Recommended to define constants upstream for flexibility.
if (\defined('USE_TWIGIT') && true === \constant('USE_TWIGIT')) {
    $twig = Twigit\Twigit::init('path/to/mysite', ['autoescape' => 'html']);

    // Apply a template filter that overrides traditional theme handling.
    $twig->templateFilter();
}

If using Raydium, many configuration steps are already handled. Learn more here: Raydium GitHub Repository.

3. Organize Your Templates

Create a templates directory in your project root:

mysite/
└── templates/
    ├── base.twig
    ├── header.twig
    └── footer.twig

You can copy and adapt Twigit's base templates from its GitHub repository: Twigit Base Templates

4. Example Twig Template

Here’s a simple example of a base Twig template:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>{{ title }}</title>
</head>
<body>
    {% block content %}
    {% endblock %}
</body>
</html>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固