Browser-based word processor for .docx and .odt files that runs locally, with no server or account required.
PHPOffice/PHPWord
A pure PHP library for creating, reading and converting Word-style documents in OOXML, ODF, RTF, HTML and PDF formats.
Open-source alternative to:Microsoft Word
- Stars
- 7,589
- Forks
- 2,731
- Open issues
- 1,238
- Last commit
- 12 days ago
What is it?
PHPWord lets PHP code generate and read word processing documents without requiring Microsoft Office or LibreOffice. It handles Office Open XML (.docx), OpenDocument (.odt) and Rich Text Format (.rtf) files, and can also write HTML and PDF output.
Documents are built through an object model: you add sections, then text runs, paragraphs, tables, lists, images, charts, headers and footers, and save with a writer chosen by format. Styles can be defined as named styles or applied inline. Templates can be filled in and existing OOXML documents can be modified.
The library is licensed under LGPL v3 and is installed via Composer. It requires PHP 7.1 or later, with optional extensions such as Zip, GD and XMLWriter enabled depending on the features used.
Key features
- 01Reads and writes .docx, .odt and .rtf files, and writes HTML and PDF.
- 02Supports sections with separate page settings, headers and footers.
- 03Inserts tables, lists, images, hyperlinks, footnotes and endnotes.
- 04Adds charts, drawing shapes and form fields.
- 05Supports table of contents, East Asian fonts and UTF-8 text.
- 06Creates documents from templates and applies XSL 1.0 style sheets to OOXML templates.
Use cases
- Generating invoices, reports or contracts as Word files from a PHP web application.
- Converting existing documents between DOCX, ODT, RTF and HTML on a server.
- Filling templates with database data to produce personalized letters in bulk.
Quick start
- 1
Install PHPWord with Composer
composer require phpoffice/phpword - 2
Create a document in a PHP script using the basic example from the README
Things to know
- Licensed under LGPL version 3, a copyleft license.
- PDF output requires the optional dompdf library.
In collections
Topics
FAQ
- What is PHPWord?
- A pure PHP library for creating, reading and converting Word-style documents in OOXML, ODF, RTF, HTML and PDF formats. PHPWord lets PHP code generate and read word processing documents without requiring Microsoft Office or LibreOffice. It handles Office Open XML (.docx), OpenDocument (.odt) and Rich Text Format (.rtf) files, and can also write HTML and PDF output.
- Is PHPWord free to use? What license does it have?
- PHPWord is open source under the Other license. Check the license terms before using it in commercial products.
- Is PHPWord still maintained?
- Actively maintained. The last commit to PHPWord was on Oct 26, 2026.
- What can I use PHPWord for?
- Generating invoices, reports or contracts as Word files from a PHP web application. Converting existing documents between DOCX, ODT, RTF and HTML on a server. Filling templates with database data to produce personalized letters in bulk.
- How do I install PHPWord?
- Install PHPWord with Composer: composer require phpoffice/phpword Create a document in a PHP script using the basic example from the README
- Where can I get PHPWord?
- The source code and installation instructions are on GitHub: https://github.com/PHPOffice/PHPWord
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A self-hosted collaborative online office suite with editors for documents, spreadsheets, presentations, forms and PDFs, compatible with .docx, .xlsx and .pptx.
Self-hosted Spring Boot service that renders online previews of Office, PDF, CAD, 3D, media, archive and many other file formats.
A free, open-source AI Office suite for macOS, Windows and Linux that edits real .docx, .xlsx, .pptx and PDF files with a built-in AI agent.
An open-source, clean-room word processor written in pure Rust that reads and writes .docx and runs on desktop and in the browser.
Browser-based editor for Word, Excel, PowerPoint and PDF files that runs locally, with no Office install or account needed.