mohammadraufzahed/folio
Composer 安装命令:
composer require mohammadraufzahed/folio
包简介
Modern PDF generation library for PHP 8.3+ with composable document model, layout engine, and custom template language
README 文档
README
A modern, production-quality PDF generation library for PHP 8.3+.
Flutter / SwiftUI / Jetpack Compose for PDFs.
Folio PDF implements its own document model, layout engine, templating engine, and PDF renderer - no wrapping of HTML-to-PDF solutions. It provides a composable, immutable design with a fluent builder API and a custom template language for declarative PDF generation.
Features
- PHP 8.3+ with strict types everywhere
- Zero Runtime Dependencies - pure PHP implementation
- Composable Document Model - immutable nodes with fluent builder API
- Custom Template Language - declarative syntax with data binding
- Layout Engine - flex and grid layouts with automatic pagination
- Comprehensive Styling - colors, fonts, borders, shadows, spacing
- Table Support - simple, nested, multi-header, and multi-level tables
- Page Chrome - themed headers and footers with page numbers
- Developer Tooling - LSP, VS Code extension, formatter, tree-sitter grammar
Installation
Install via Composer:
composer require folio/pdf
Requirements
- PHP 8.3 or higher
- Composer for dependency management
- No external dependencies or extensions required
Quick Start
PHP Builder API
use Folio\Pdf\Document\Pdf; use Folio\Pdf\Nodes\Column; use Folio\Pdf\Nodes\Heading; use Folio\Pdf\Nodes\Page; use Folio\Pdf\Nodes\Text; use Folio\Pdf\Styling\Color; use Folio\Pdf\Styling\Style; Pdf::make() ->page( Page::a4()->withContent( Column::make() ->addChildren([ Heading::h1('Invoice'), Text::make('Customer: John Doe'), Text::make('Amount: $100.00'), ]) ) ) ->save('invoice.pdf');
Template Language
var title = "Invoice"
var customer = "John Doe"
page {
heading title
text "Customer: " customer
text "Amount: $100.00"
}
use Folio\Pdf\Template\PhpTemplateCompiler; $compiler = new PhpTemplateCompiler(); $pdf = $compiler->renderFile('invoice.folio', [ 'title' => 'Invoice', 'customer' => 'John Doe', ]); $pdf->save('invoice.pdf');
Documentation
Full documentation is available at mohammadraufzahed.github.io/folio
- Getting Started - Installation and basic usage
- API Reference - Complete API documentation
- Template Language - Template syntax and features
- Examples - Real-world usage examples
- Tooling - LSP, formatter, and VS Code extension
Architecture
Folio PDF is built with a clean, modular architecture:
- Document Model - Immutable AST nodes (Page, Column, Row, Text, Table, etc.)
- Layout Engine - Flex and grid layout calculations with automatic pagination
- Template Compiler - Lexer, parser, and PHP code generator for templates
- Styling System - Comprehensive style properties with type safety
- PDF Writer - Direct PDF generation without external dependencies
Key Concepts
Immutable Design
All document nodes are immutable. Methods like withStyle() return new instances:
$page = Page::a4(); $styledPage = $page->withContent($content); // Returns new instance
Composable Layouts
Build complex layouts from simple components:
Column::make() ->addChildren([ Heading::h2('Section 1'), Text::make('Content here'), Row::make()->addChildren([ Text::make('Left'), Text::make('Right'), ]), ])
Styling
Apply styles with a fluent API:
Style::make() ->withPadding(20.0) ->withColor(Color::hex('#333333')) ->withFontSize(14.0) ->withFontWeight(FontWeight::Bold)
Examples
See the examples/ directory for complete working examples:
hello-world.php- Basic PDF generationinvoice.php- Invoice with tables and stylingcompany-report.php- Multi-page document with headers/footerstables.php- Various table configurations
Development
Running Tests
composer test
Static Analysis
composer analyze
Code Style
Follow PSR-12 coding standards. Use strict types and type hints throughout.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Report bugs via GitHub Issues
- Submit pull requests for improvements
- Discuss features in GitHub Discussions
Security
For security vulnerabilities, please email security@folio-pdf.dev instead of using public issues. See SECURITY.md for details.
License
MIT License - see LICENSE file for details.
Acknowledgments
- Inspired by Flutter, SwiftUI, and Jetpack Compose design patterns
- Built with modern PHP 8.3+ features
- Community-driven open-source project
Links
mohammadraufzahed/folio 适用场景与选型建议
mohammadraufzahed/folio 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 07 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「template」 「pdf」 「document」 「layout」 「report」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mohammadraufzahed/folio 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mohammadraufzahed/folio 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mohammadraufzahed/folio 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Simple ASCII output of array data
E2E Studios PHP Framework adaptation of leafsphp/blade package
Provides TCPDF integration for Symfony
Phalcon Model Generator
Auto-generate dummy data with realistic relationships per Model-like config classes
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-15