Documentation Index
Fetch the complete documentation index at: https://docs.mejik.web.id/llms.txt
Use this file to discover all available pages before exploring further.
Integrating docling with Laravel Artisan
This guide explains how to call the docling command-line tool from a Laravel Artisan command. This is useful for automating document conversion tasks within your web application.
Key Concepts
When running an Artisan command, the PHP process executes in a non-interactive shell. This means it doesn’t have the same environment as your user’s terminal session. Therefore, you cannot simplysource the virtual environment’s activation script.
Instead, you must use the absolute path to the docling executable within the virtual environment.
Steps for Integration
-
Locate the
doclingExecutable: The absolute path to thedoclingexecutable in the virtual environment we created is: -
Create a New Artisan Command: You can create a new Artisan command using the following command:
-
Implement the Command: Open the newly created
app/Console/Commands/ConvertDocument.phpfile and modify it to use theProcesscomponent to execute thedoclingcommand. Here is a complete example: -
File Permissions: The user that runs your web server (e.g.,
www-data,nginx,apache) needs to have execute permissions on thedoclingexecutable and read/write permissions on the directories where your input and output files are stored. You can ensure the executable has the correct permissions with:You will also need to ensure that yourstorage/appdirectory (or wherever you are storing your files) is writable by the web server user.
Usage
Once you have created the Artisan command, you can run it from your terminal like any other command:my_document.pdf file located in storage/app to my_converted_document.docx in the same directory.