Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Office Converter Laravel Package

mattmy/laravel-office-converter

mattmy/laravel-office-converter is a Laravel package for simplifying office document conversion. It offers a convenient integration and clean API for converting files within your application, helping you add document conversion workflows quickly with minimal setup.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Install the package with Composer per its README, then publish any config if the package exposes it (php artisan vendor:publish --tag=...). Pin ^0.2.1 while the package is pre-1.0.
  • Check first: the README usage example, config/office-converter.php (or equivalent), the package exception classes, and tests covering temporary workspaces/cleanup.
  • Configure the office executable path and a dedicated writable temporary directory. Do not use a filesystem root as the temp directory; use something like storage/app/office-converter/tmp.
  • First use case: accept an uploaded .docx/.xlsx/.pptx, convert it to PDF in a queued job, store the result on a Laravel disk, and return/download the stored file. Catch package exceptions and surface a user-safe validation/conversion error.

Implementation Patterns

  • Wrap conversions in queued jobs for anything beyond tiny documents. Keep HTTP controllers thin: validate upload, dispatch job, track status, then expose the stored output.
  • Treat document and conversion-result objects as single-owner resources. Do not clone them in application code; create a fresh conversion/document instance per job or per output format.
  • Use explicit cleanup in finally blocks even though the package retries cleanup on destruction. This is especially important in long-running queue workers where destructor timing can be delayed.
  • Store source and converted files on Laravel disks, but give the package real local paths or streams as required. Keep package temp directories isolated per job/process where possible.
  • Catch package-specific exceptions rather than relying on generic filesystem warnings. Map them to domain errors such as “unsupported document”, “invalid OOXML”, “conversion failed”, and “temporary workspace unavailable”.
  • Validate uploads before conversion: extension/MIME, non-empty file, ZIP/OOXML readability where relevant, and reasonable size limits. The package now rejects empty or invalid UTF-8 OOXML entries consistently, but failing early gives better UX.
  • If snapshot creation fails, assume any source stream passed in may have been closed. Reopen the stream/file for retries instead of reusing the failed resource.
  • Keep executable and temp-directory config values clean. Avoid multiline env values or hidden control characters; v0.2.1 rejects NUL bytes in these settings.

Gotchas and Tips

  • v0.2.1 is primarily a hardening patch, but the clone prevention is behaviorally significant. If existing code cloned document or conversion-result objects, refactor to construct fresh instances and test conversion/cleanup paths.
  • Do not configure the temporary directory as / or a drive root. The workspace containment check was fixed for root temp directories, but a root temp dir is still an unnecessary security/cleanup risk.
  • Cleanup is retried when a document is destroyed, so deletion may not be immediate. Do not assume the temp file is gone the instant a conversion finishes; avoid reusing predictable temp filenames.
  • Filesystem warnings are now mapped to package exceptions. Catch those exceptions specifically and log the original context (source path, target format, temp directory) for debugging.
  • Invalid or empty OOXML entries now fail with consistent exceptions. If users upload corrupted Office files, expect conversion to fail at validation/snapshot time rather than producing a partial output.
  • Because this is a 0.x package, review release notes before upgrading. Pin the version in production and run conversion/cleanup tests against representative DOCX/XLSX/PPTX files.
  • Debugging checklist: confirm the executable is installed and callable by the PHP/queue user, confirm the temp directory is writable and not a root, inspect package exceptions rather than only Laravel logs, and verify queue worker permissions match web/CLI expectations.
  • Extension points to watch: config for executable/temp paths, package exception hierarchy, format mappings, and document/conversion factories or constructors. Prefer fresh instances and explicit cleanup over cloning or reusing partially failed objects.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package