https://github.com/innobraingmbh/markitdown
Laravel bindings to microsoft/markitdown
https://github.com/innobraingmbh/markitdown
laravel markdown markitdown
Last synced: 6 months ago
JSON representation
Laravel bindings to microsoft/markitdown
- Host: GitHub
- URL: https://github.com/innobraingmbh/markitdown
- Owner: innobraingmbh
- License: mit
- Created: 2024-12-16T13:04:48.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-25T07:35:07.000Z (9 months ago)
- Last Synced: 2025-09-25T09:24:01.385Z (9 months ago)
- Topics: laravel, markdown, markitdown
- Language: PHP
- Homepage:
- Size: 130 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel bindings for markitdown.
[](https://packagist.org/packages/innobrain/markitdown)
[](https://github.com/innobraingmbh/markitdown/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/innobraingmbh/markitdown/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[](https://packagist.org/packages/innobrain/markitdown)
Laravel bindings for markitdown.
## Installation
1. Install the package via composer:
```bash
composer require innobrain/markitdown
```
2. Publish the configuration file:
```bash
php artisan vendor:publish --tag="markitdown-config"
```
3. Run the installation command if you want the package to manage your `markitdown` installation:
```bash
php artisan markitdown:install
```
This will:
- Set up a Python virtual environment with the required dependencies
- Add the setup script to your project's composer.json
- Ensure the environment is kept up to date with future composer updates
### Alternative Installation Methods
If you prefer not to use the built-in virtual environment, you can disable it in your `.env` file or in the config:
```bash
MARKITDOWN_USE_VENV_PACKAGE=false
```
Then install markitdown manually using one of these methods:
#### Using pip directly:
```bash
pip install markitdown
```
#### Using pipx (Recommended for manual installation):
On macOS:
```bash
brew install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
```
Or see how to install on [other platforms](https://github.com/pypa/pipx).
After installing `pipx`, you can install `markitdown` with:
```bash
pipx install markitdown
```
When not using the built-in virtual environment, you'll need to set the path to the `markitdown` executable in your `.env` file. You can retrieve the path with:
```bash
which markitdown
```
```bash
MARKITDOWN_EXECUTABLE=/path/to/markitdown
```
Also, when running the script anywhere but the console, you need to set the PATH, as php-fpm does not have
access to the PATH variable. You can do this by adding the following to your `.env` file:
```bash
MARKITDOWN_SYSTEM_PATH=
```
## Configuration
The package's configuration will be published to `config/markitdown.php`. Here are the available options:
```php
return [
/*
* Use this to set the timeout for the process. Default is 30 seconds.
*/
'process_timeout' => env('MARKITDOWN_PROCESS_TIMEOUT', 30),
/*
* Use this to set the path to the markitdown executable. If not set,
* the binary will be searched in the PATH. Will be ignored
* if use_venv_package is set to true.
*/
'executable' => env('MARKITDOWN_EXECUTABLE', 'markitdown'),
/*
* This will override the above setting and use the new locally installed package.
*/
'use_venv_package' => env('MARKITDOWN_USE_VENV_PACKAGE', true),
/*
* This is needed when you want to run markitdown in php-fpm. One dependency
* of markitdown requires PATH to be set. If you are running in a console,
* this is not needed.
*/
'system' => [
'path' => env('MARKITDOWN_SYSTEM_PATH', ''),
],
/*
* The path where temporary files will be stored. This directory must be writable
* by the web server. Defaults to storage/app/private/markitdown_tmp
*/
'temporary_directory' => env('MARKITDOWN_TEMPORARY_DIRECTORY', storage_path('app/private/markitdown_tmp')),
];
```
## Usage
```php
// convert a file:
$markdown = \Innobrain\Markitdown\Facades\Markitdown::convert('/path/to/file.docx');
// or convert a file you already have in memory:
$file = file_get_contents('/path/to/file.docx');
$markdown = \Innobrain\Markitdown\Facades\Markitdown::convertFile($file, '.docx');
```
## Testing
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Credits
- [Konstantin Auffinger](https://github.com/kauffinger)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.