Download the PHP package hosmelq/laravel-anydoc without Composer
On this page you can find all versions of the php package hosmelq/laravel-anydoc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hosmelq/laravel-anydoc
More information about hosmelq/laravel-anydoc
Files in hosmelq/laravel-anydoc
Package laravel-anydoc
Short Description Laravel integration for converting documents to GitHub-Flavored Markdown with Firecrawl anydoc.
License MIT
Informations about the package laravel-anydoc
Laravel anydoc
Convert documents to GitHub-Flavored Markdown in Laravel applications, with access to anydoc's structured document model when available.
Requirements
- ext-anydoc ^0.2.4
- Laravel 12+
- PHP 8.4+
Installation
Install the native extension with PIE:
Install Laravel anydoc with Composer:
Convert documents
Convert a local file to Markdown with the Anydoc facade:
file() also accepts an uploaded file:
Convert document bytes directly:
CSV has no content signature, so CSV bytes require an explicit format:
All conversions run synchronously.
Convert files from disks
Convert a file stored on a Laravel filesystem disk:
Call Anydoc::disk() without a name to use Laravel's default disk.
Disk files and uploaded files are read into memory before conversion.
Read structured documents
Call document() to access anydoc's readonly document model:
The document model includes blocks, checkboxes, embedded assets, inline content, lists, math, notes, and tables.
PDF supports Markdown conversion only. Calling document() for a PDF throws an
Anydoc\Exception\UnsupportedException.
Supported formats
| Format | Extensions |
|---|---|
| CSV | .csv |
| EPUB | .epub |
| Excel | .xls, .xlsb, .xlsm, .xlsx |
| OpenDocument | .odp, .ods, .odt |
.pdf |
|
| PowerPoint | .pot, .pps, .ppsm, .ppsx, .ppt, .pptm, .pptx |
| Rich Text Format | .rtf |
| Word | .doc, .docm, .docx |
Pass a Format enum case when the format cannot be detected from the content:
Detect formats
Detect a format from bytes, an extension, or a path:
Each method returns a Format enum case or null. Extension detection is
case-insensitive and accepts an optional leading dot.
Uploaded files use their contents first and their original name as a fallback. Filesystem files use their contents first and their path as a fallback.
Use dependency injection
Inject the Anydoc contract when a class should not depend on the facade:
Handle errors
Native conversion errors extend Anydoc\Exception\ConvertException:
Conversion exceptions include EncryptedException, IoException,
MalformedException, MissingPartException, NeedsOcrException,
ResourceLimitException, and UnsupportedException. NeedsOcrException
provides the 1-indexed PDF pages requiring OCR through $pages and the total
number of pages through $pageCount. Filesystem sources may also throw Laravel
filesystem exceptions when their contents cannot be read.
PanicException represents a panic from the native Rust library and does not
extend ConvertException.
Test conversions
Call Anydoc::fake() to test application behavior without reading files or
running conversions:
Use a closure when the response depends on the recorded conversion:
The fake provides assertions and access to recorded conversions:
Assertion and filtering callbacks receive a RecordedConversion containing
its disk, format, input, output type, and source type. A conversion is recorded
when markdown() or document() is called.
The default fake Markdown response is an empty string. Document conversions
require a configured Anydoc\Document response.
Development
Run the test suite with:
Changelog
See CHANGELOG.md for a list of changes.
Contributing
Pull requests are welcome. Please run the test suite before submitting changes.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-anydoc with dependencies
ext-anydoc Version ^0.2.4
illuminate/filesystem Version ^12.0 || ^13.0
illuminate/http Version ^12.0 || ^13.0
illuminate/support Version ^12.0 || ^13.0
spatie/laravel-package-tools Version ^1.93
thecodingmachine/safe Version ^3.4