zahfouf/php-libreoffice
最新稳定版本:v1.2.3
Composer 安装命令:
composer require zahfouf/php-libreoffice
包简介
Framework-agnostic LibreOffice headless document conversion library for PHP.
README 文档
README
Simple PHP package to convert Word files (.doc, .docx) to PDF using LibreOffice (soffice) in headless mode.
Installation
composer require zahfouf/php-libreoffice
CLI Commands
After installation, the CLI binary is available at:
vendor/bin/libreoffice
lo:install
Installs LibreOffice automatically on Ubuntu/Debian.
vendor/bin/libreoffice lo:install
Notes:
- Windows: automatic installation is not supported (the command prints the official download URL).
- Non-Debian/Ubuntu Linux: install LibreOffice using your distribution package manager.
lo:probe
Checks that the LibreOffice binary works and saves default values:
- binary path (
binary) - temporary directory (
temp_dir)
vendor/bin/libreoffice lo:probe --binary="C:\Program Files\LibreOffice\program\soffice.exe" --temp-dir="C:\laragon\tmp"
These values are stored in src/Config/global_options.php.
lo:convert
Converts a Word document to PDF.
vendor/bin/libreoffice lo:convert "C:\docs\invoice.docx" --to=pdf --out="C:\docs\out"
Useful options:
--binary: path tosoffice--timeout: timeout in seconds--temp-dir: temporary directory--profile: strategy (none|per_job|per_worker|shared_mutex)--worker-id: worker id (forper_worker)--keep-temp: keep temporary files on failure
Usage example (code)
<?php use LibreOffice\LibreOffice; $lo = new LibreOffice(); $result = $lo->convert('C:/docs/report.docx')->to('pdf', ['output_dir' => 'C:/docs/out']); echo $result->outputPath . PHP_EOL; echo $result->durationMs . PHP_EOL; // Static usage (without instantiating): $result = LibreOffice::make()->convert('C:/docs/report.docx')->to('pdf', ['output_dir' => 'C:/docs/out']);
Test
composer test
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-15