pixelbrackets/html5-mini-template
Composer 安装命令:
composer require pixelbrackets/html5-mini-template
包简介
HTML5 Mini Template for quick rendering of status pages, TOC pages, or any other minimal single-serving site
关键字:
README 文档
README
HTML5 Mini Template for quick rendering of status pages, TOC pages, or any other minimal single-serving site.
![]()
⭐ You like this package? Please star it or send a tweet. ⭐
Vision
This package provides a single class to turn a message or HTML-snippet into a valid HTML5 document.
This way it is possible to let an app return an HTML response without the need to store a template file beforehand or initialize a full-blown template engine.
The package therefore does not have template variables or modifiers. Two lines of code should be sufficient to wrap a given text into a valid HTML document. One more to add a link to fancy stylesheet.
See »Usage« for some examples.
The package follows the KISS principle.
When to Use This
Use HTML5 Mini Template when you need to:
- Generate a simple HTML page without template files or a template engine
- Return HTML responses from a PHP script with minimal setup
- Create single-serving pages (status, error, placeholder) programmatically
- Avoid adding template engine dependencies for trivial HTML output
You might want to use an alternative if you need:
- Multiple templates or layouts → use Twig or Blade
- Template variables, loops, conditionals → use slim/php-view
- A full frontend build system → use a static site generators like Hugo or Jekyll
- Complex multi-page sites → use a framework with proper templating
Webapp
This package is used on html5example.com.
If you are in need of a boilerplate HTML document once only, then you may use a
commandline tool like cURL or HTTPie and run
http https://html5example.com > index.html to save a template file.
The webapp supports some options of this package as well,
for example
http POST https://html5example.com title=Minimal-Template > index.html
to pass a custom title.
Requirements
- PHP
Installation
Packagist Entry https://packagist.org/packages/pixelbrackets/html5-mini-template/
Source
https://gitlab.com/pixelbrackets/html5-mini-template/
Mirror https://github.com/pixelbrackets/html5-mini-template/ (Issues & Pull Requests mirrored to GitLab)
Demo
Usage
Wrap a message into a HTML5 document, return to a PSR-7 implementation
$template = new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate(); $template->setContent('<h1>Status</h1><p>All Systems Operational</p>'); return $template->getMarkup();Wrap a message, use a preconfigured CSS framework CDN (see »options« for a list of supported frameworks), and save the document into a file
$template = new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate(); $template->setStylesheet('barbone'); $template->setContent('<h1>Index</h1><p>Nothing to see here</p>'); file_put_contents('/var/www/example/index.html', $template->getMarkup());Wrap a message, set your own stylesheet URL, set a title, output the document
$template = (new \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate()) ->setStylesheet('/assets/styles.css') ->setTitle('Index') ->setContent('<h1>TOC</h1><ul><li>a</li><li>b</li></ul>'); echo $template->getMarkup();Get the boilerplate example template only (👉 or use the Webapp)
echo \Pixelbrackets\Html5MiniTemplate\Html5MiniTemplate::getTemplate();
Common Use Cases:
- Status pages - Generate "All Systems Operational" or maintenance pages
- Error pages - Create custom 404, 500, or maintenance error responses
- CLI tool HTML output - Wrap command-line tool output in viewable HTML
- Build artifacts - Generate HTML reports, coverage summaries, or changelogs
- Email templates - Create simple HTML emails without a template engine
- API documentation landing pages - Quick index pages for API endpoints
- Placeholder pages - "Coming soon" or "Under construction" pages
- Print-friendly output - Convert data to styled, printable HTML documents
Options
setContent()(string) the message to show, any HTML string to set the main content of the document – if empty, then a boilerplate example content is used instead- 💭 You work with Markdown content? Use the drop-in replacement package pixelbrackets/markdown-mini-page to convert Markdown into HTML straightaway
setStylesheet()(string) may be a URL to any existing stylesheet or one of following reserved keywords – each keyword creates a link to a CDN of the associated CSS frameworkbarebone(Barebone Stylesheet) – super lightweightbootstrap(Bootstrap)gfm(GitHub Flavored Markdown Stylesheet)milligram(Milligram)minicss(mini.css)mui(MUI - Material Design CSS Framework)mvp(MVP.css)picnic(Picnic CSS)skeleton(Skeleton)
setStylesheetMode()(string) switch between a link to the given stylesheet (using the constantHtml5MiniTemplate::STYLE_LINK, this is the default mode) or fetch the stylesheet file content and print it inline (using the constantHtml5MiniTemplate::STYLE_INLINE)setTitle()(string) the document title – if empty, then the first H1 headline found in the main content is used as title insteadsetAdditionalMetadata()(string) any additional metadata like metatags, custom styles or link references like a canonical link- ⚠️ Usage of this option is an indicator that the given use case is too specific and switching to a template engine like the minimal slim/php-view or the powerfull twig/twig should be considered
License
GNU General Public License version 2 or later
The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html.
Author
Dan Kleine (mail@pixelbrackets.de / @pixelbrackets)
Changelog
See CHANGELOG.md
Contribution
This script is Open Source, so please use, share, patch, extend or fork it.
Contributions are welcome!
Feedback
Please send some feedback and share how this package has proven useful to you or how you may help to improve it.
pixelbrackets/html5-mini-template 适用场景与选型建议
pixelbrackets/html5-mini-template 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.52k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 08 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「template」 「HTML5」 「single-page」 「status-page」 「html-generator」 「html-boilerplate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pixelbrackets/html5-mini-template 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pixelbrackets/html5-mini-template 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pixelbrackets/html5-mini-template 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
HTML5 support for SilverStripe
HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.
The yii2-videojs-widget is a Yii 2 wrapper for the [video.js](http://www.videojs.com/). A JavaScript and CSS library that makes it easier to work with and build on HTML5 video. This is also known as an HTML5 Video Player.
Simple ASCII output of array data
Handle file uploading.
E2E Studios PHP Framework adaptation of leafsphp/blade package
统计信息
- 总下载量: 13.52k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 34
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2019-08-05