承接 zahfouf/php-libreoffice 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

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 to soffice
  • --timeout: timeout in seconds
  • --temp-dir: temporary directory
  • --profile: strategy (none|per_job|per_worker|shared_mutex)
  • --worker-id: worker id (for per_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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固