PHPackages                             coolms/ooxml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. coolms/ooxml

ActiveLibrary

coolms/ooxml
============

Writing Open Packaging Conventions containers in pure PHP: a deterministic ZIP writer, OPC parts, content types and relationships, and the escaping OOXML needs. Format-agnostic — it knows nothing about workbooks or documents.

00PHPCI passing

Since Aug 27Pushed yesterdayCompare

[ Source](https://github.com/coolms/ooxml)[ Packagist](https://packagist.org/packages/coolms/ooxml)[ RSS](/packages/coolms-ooxml/feed)WikiDiscussions develop Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

coolms/ooxml
============

[](#coolmsooxml)

[![PHP](https://camo.githubusercontent.com/2b52414cdbb9b3ded58489d546954dfbdf2e9292ec75252c4be2c4979e5a7623/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135253230382e352d373737626234)](https://www.php.net/releases/8.5/en.php)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)

**Writing Office Open XML containers in pure PHP.** A deterministic ZIP writer, OPC parts, content types, relationships, and the escaping OOXML needs — and no knowledge of workbooks, documents or decks.

```
$package = new OpcPackage();
$package->declareDefault('rels', 'application/vnd.openxmlformats-package.relationships+xml');
$package->declareDefault('xml', 'application/xml');

$package->addPart('xl/worksheets/sheet1.xml', $sheetXml, self::WORKSHEET_TYPE);
$rId = $package->relate('xl/workbook.xml', self::REL_NS . '/worksheet', 'xl/worksheets/sheet1.xml');

$package->addPart('xl/workbook.xml', $workbookXml, self::WORKBOOK_TYPE);
$package->relate('', self::REL_NS . '/officeDocument', 'xl/workbook.xml');

file_put_contents('book.xlsx', $package->toBytes());
```

What it is for
--------------

[](#what-it-is-for)

`.xlsx`, `.docx` and `.pptx` differ only in their parts. The container around them — the zip, `[Content_Types].xml`, the `.rels` graph — is identical, and is the part that decides whether Office opens the file at all. This package is that container; the parts belong to whatever knows the document model.

What it deliberately refuses
----------------------------

[](#what-it-deliberately-refuses)

- **A part with no content type.** Not a default — a package Office rejects.
- **A relationship target outside the source part's folder.** Legal OOXML, but it needs `../` segments this has not reasoned about, and a path written by guesswork opens as a document with a piece silently missing.
- **Text it cannot escape.** A failed strip throws rather than returning an empty string, because an empty cell and a destroyed one look identical.

Deterministic by design
-----------------------

[](#deterministic-by-design)

Entries carry a fixed timestamp, so the same input produces the same bytes. PHP's own `ZipArchive` cannot write to a string — every archive goes through a temporary file — and stamps the current time, which means no test may ever compare two artifacts. That, not performance, is why the ZIP writer is here.

Requirements
------------

[](#requirements)

PHP 8.5+, `ext-zlib`. No runtime dependencies.

Licence
-------

[](#licence)

MIT.

###  Health Score

21

—

LowBetter than 17% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/091dc5e6e8002ab857d5d212ff5b3160e67b9c20849d6bd2a98dbe8ce5477c63?d=identicon)[coolms](/maintainers/coolms)

---

Top Contributors

[![thugstar](https://avatars.githubusercontent.com/u/7189630?v=4)](https://github.com/thugstar "thugstar (4 commits)")

### Embed Badge

![Health badge](/badges/coolms-ooxml/health.svg)

```
[![Health](https://phpackages.com/badges/coolms-ooxml/health.svg)](https://phpackages.com/packages/coolms-ooxml)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
