daily-five/plates-components
Composer 安装命令:
composer require daily-five/plates-components
包简介
This is a Plates PHP template engine extension for easy build reusable nested components.
README 文档
README
This extension brings Laravel's powerful components and slots feature to the Plates template engine, enabling you to build reusable components using native PHP. If you appreciate the component-based architecture found in modern frontend frameworks like Vue.js, this extension provides a familiar and efficient way to structure your views.
Table of contents
Usage
To demonstrate how cool Components are, let's make an empty-state-container component on the top of tailwindcss and Lucide Icons.
Structure:
app/
├── templates/ # Application templates
│ ├── components/ # Reusable components
│ │ └── empty-state-container.php
│ └── main-layout.php
└── index.php
File: index.php
<?php
// Composer autoloader
require_once 'vendor/autoload.php';
// Create an instance of the template engine
$templateEngine = new \League\Plates\Engine('templates');
// Load the components extension
$templateEngine->loadExtension(new \DailyFive\PlatesExtensions\Components());
// Render the template
echo $templateEngine->render('main-layout');
File: templates/main-layout.php
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Plates Components are cool</title>
<script src="https://unpkg.com/@tailwindcss/browser@4"></script>
<script src="https://unpkg.com/lucide@1"></script>
</head>
<body>
<div class="max-w-lg mx-auto py-8 space-y-4">
<?= $this->component('components/empty-state-container') ?>
<?= $this->slot('icon') ?>
<i data-lucide="check" class="size-18"></i>
<?= $this->endSlot() ?>
<?= $this->slot('title') ?>
Greate Job
<?= $this->endSlot() ?>
<?= $this->slot('message') ?>
You've done all your work today!
<?= $this->endSlot() ?>
<?= $this->endComponent() ?>
<?= $this->component('components/empty-state-container') ?>
<?= $this->slot('icon') ?>
<i data-lucide="inbox" class="size-18"></i>
<?= $this->endSlot() ?>
<?= $this->slot('title') ?>
Empty
<?= $this->endSlot() ?>
<?= $this->slot('message') ?>
There are no projects you can handle!
<?= $this->endSlot() ?>
<?= $this->slot('action') ?>
<a class="text-sm no-underline hover:opacity-50 transition-opacity rounded-sm px-4 py-2 mb-2 inline-block text-white bg-green-800" href="#0">Create a new project</a>
<?= $this->endSlot() ?>
<?= $this->endComponent() ?>
</div>
<script>
lucide.createIcons();
</script>
</body>
</html>
File: templates/components/empty-state-container.php
<div class="bg-gray-50 border border-gray-100 rounded-xl space-y-8 py-8">
<?php if (isset($icon)): ?>
<div class="text-center text-gray-500 flex justify-center"><?= $icon ?></div>
<?php endif; ?>
<div class="space-y-2">
<?php if (isset($title)): ?>
<div class="text-center text-2xl text-gray-500"><?= $title ?></div>
<?php endif; ?>
<?php if (isset($message)): ?>
<div class="text-center text-xl"><?= $message ?></div>
<?php endif; ?>
</div>
<?php if (isset($action)): ?>
<div class="text-center"><?= $action ?></div>
<?php endif; ?>
<?= $slot ?? '' ?>
</div>
Installation
Install via CLI
composer require daily-five/plates-components
If you have permission problems at installation, try this solution
Contributing
Please see CONTRIBUTING for details.
License
The Plates extension is licensed under the MIT license.
daily-five/plates-components 适用场景与选型建议
daily-five/plates-components 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.22k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 02 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「templating」 「template」 「components」 「views」 「nested」 「slots」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 daily-five/plates-components 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 daily-five/plates-components 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 daily-five/plates-components 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
A Processor for Markup written in PHP. Allows extraction of Markup into a data structure, orchestrated nested manipulation of said structure, and output as (optimized) Markup.
Web Font Loader gives you added control when using linked fonts via @font-face.
Simple ASCII output of array data
Ariadne Component Library: xml writer and parser Component
E2E Studios PHP Framework adaptation of leafsphp/blade package
统计信息
- 总下载量: 1.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 25
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-03