定制 mohammadraufzahed/folio 二次开发

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

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

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

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 generation
  • invoice.php - Invoice with tables and styling
  • company-report.php - Multi-page document with headers/footers
  • tables.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.

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 mohammadraufzahed/folio 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-15