Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

PHPWord

> 前端框架
Open source

A pure PHP library for reading and writing word processing documents

7.6K stars0 likes3 views
WebsiteGitHub

About

A pure PHP library for reading and writing word processing documents

Branch Master :

PHPWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of PHPWord supports Microsoft Office Open XML (OOXML or OpenXML), OASIS Open Document Format for Office Applications (OpenDocument or ODF), Rich Text Format (RTF), HTML, and PDF.

PHPWord is an open source project licensed under the terms of LGPL version 3. PHPWord is aimed to be a high quality software product by incorporating continuous integration and unit testing. You can learn more about PHPWord by reading the Developers' Documentation.

If you have any questions, please ask on StackOverFlow

Read more about PHPWord:

  • Features
  • Requirements
  • Installation
  • Getting started
  • Contributing
  • Developers' Documentation

Features

With PHPWord, you can create OOXML, ODF, or RTF documents dynamically using your PHP scripts. Below are some of the things that you can do with PHPWord library:

  • Set document properties, e.g. title, subject, and creator.
  • Create document sections with different settings, e.g. portrait/landscape, page size, and page numbering
  • Create header and footer for each sections
  • Set default font type, font size, and paragraph style
  • Use UTF-8 and East Asia fonts/characters
  • Define custom font styles (e.g. bold, italic, color) and paragraph styles (e.g. centered, multicolumns, spacing) either as named style or inline in text
  • Insert paragraphs, either as a simple text or complex one (a text run) that contains other elements
  • Insert titles (headers) and table of contents
  • Insert text breaks and page breaks
  • Insert and format images, either local, remote, or as page watermarks
  • Insert binary OLE Objects such as Excel or Visio
  • Insert and format table with customized properties for each rows (e.g. repeat as header row) and cells (e.g. background color, rowspan, colspan)
  • Insert list items as bulleted, numbered, or multilevel
  • Insert hyperlinks
  • Insert footnotes and endnotes
  • Insert drawing shapes (arc, curve, line, polyline, rect, oval)
  • Insert charts (pie, doughnut, bar, line, area, scatter, radar)
  • Insert form fields (textinput, checkbox, and dropdown)
  • Create document from templates
  • Use XSL 1.0 style sheets to transform headers, main document part, and footers of an OOXML template
  • ... and many more features on progress

Requirements

PHPWord requires the following:

  • PHP 7.1+
  • XML Parser extension
  • Laminas Escaper component
  • Zip extension (optional, used to write OOXML and ODF)
  • GD extension (optional, used to add images)
  • XMLWriter extension (optional, used to write OOXML and ODF)
  • XSL extension (optional, used to apply XSL style sheet to template )
  • dompdf library (optional, used to write PDF)

Installation

PHPWord is installed via Composer. To add a dependency to PHPWord in your project, either

Run the following to use the latest stable version

bash
composer require phpoffice/phpword

or if you want the latest unreleased version

bash
composer require phpoffice/phpword:dev-master

Getting started

The following is a basic usage example of the PHPWord library.

…

More examples are provided in the samples folder. For an easy access to those samples launch php -S localhost:8000 in the samples directory then browse to http://localhost:8000 to view the samples. You can also read the Developers' Documentation for more detail.

Contributing

We welcome everyone to contribute to PHPWord. Below are some of the things that you can do to contribute.

  • Read our contributing guide.
  • Fork us and request a pull to the master branch.
  • Submit bug reports or feature requests to GitHub.
  • Follow @PHPOffice on Twitter.

Issues· 1239 open

View all issuesOpen on GitHub
  • #2286

    TOC error after upgrading OpenOffice from 7.2.7.2 to higher

    Bug ReportOpen XML (Word 2007+)Updated Sep 29, 2026
  • #2938

    Insert an existing DOCX document into a section (w:altChunk)

    Change RequestUpdated Sep 26, 2026
  • #69

    Implement WPS Writer

    Change RequestUpdated Sep 13, 2026
  • #2585

    Invalid image: zip:///tmp/......../iamge4.png

    Bug ReportOpen XML (Word 2007+)Status: Waiting for feedbackUpdated Sep 9, 2026
  • #2896

    TemplateProcessor::setImageValue() inserts images as legacy VML — not editable in Word Mobile / Word Online

    Bug ReportUpdated Aug 28, 2026
  • #2923

    Writer ODText: support PreserveText fields

    Updated Aug 25, 2026
  • #1363

    Table/cell styles applied to odt file

    Bug ReportOpen Document (ODT)Updated Aug 25, 2026
  • #2895

    Add MacroExists public method to TemplateProcessor.php

    Change RequestUpdated Aug 18, 2026
  • #2846

    Does PHPWord support content control checkboxes

    Updated Jul 29, 2026
  • #2588

    Race condition in ZipArchive::$tempDir

    Bug ReportUpdated Jul 6, 2026

> Tags

PHPdocdocxhtmllibreoffice-writer

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 2, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架