mindee / mindee
Mindee Client Library for PHP
Installs: 25 543
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 3
Open Issues: 1
Requires
- php: >=7.4
- ext-curl: *
- ext-fileinfo: *
- ext-json: *
- setasign/fpdf: ^1.8
- setasign/fpdi: ^2.6
- symfony/console: >=5.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.38
- madewithlove/license-checker: ^0.10.0
- phpunit/phpunit: ^9.6
- squizlabs/php_codesniffer: ^3.7
Suggests
- ext-imagick: Required for PDF rasterization and image processing features
- ghostscript/ghostscript: Required for PDF rasterization features
This package is auto-updated.
Last update: 2024-10-30 09:57:40 UTC
README
Mindee API Helper Library for PHP
Quickly and easily connect to Mindee's API services using PHP.
Quick Start
Here's the TL;DR of getting started.
First, get an API Key
If you do not have them, you'll need the following packages on your system:
- php-curl
- php-json (not necessary for versions >= 8.0.0)
- php-fileinfo
Then, install this library:
composer require mindee/mindee
Finally, PHP away!
Loading a File and Parsing It
Global Documents
<?php use Mindee\Client; use Mindee\Product\Invoice\InvoiceV4; // Init a new client $mindeeClient = new Client("my-api-key"); // Load a file from disk $inputSource = $mindeeClient->sourceFromPath("/path/to/the/file.ext"); // Parse the file $apiResponse = $mindeeClient->parse(InvoiceV4::class, $inputSource); // Print a brief summary of the parsed data echo strval($apiResponse->document);
Note: Files can also be loaded from:
A PHP File
compatible file:
$inputDoc = $mindeeClient->sourceFromFile($myFile);
A URL (HTTPS
only):
$inputDoc = $mindeeClient->sourceFromUrl("https://files.readme.io/a74eaa5-c8e283b-sample_invoice.jpeg");
A base64-encoded string, making sure to specify the extension of the file name:
$inputDoc = $mindeeClient->sourceFromB64($myInputString, "my-file-name.ext");
Raw bytes, making sure to specify the extension of the file name:
$inputDoc = $mindeeClient->sourceFromBytes($myRawBytesSequence, "my-file-name.ext");
Region-Specific Documents
use Mindee\Client; use Mindee\Product\Us\BankCheck\BankCheckV1; // Init a new client $mindeeClient = new Client("my-api-key"); // Load a file from disk $inputSource = $mindeeClient->sourceFromPath("/path/to/the/file.ext"); // Parse the file $apiResponse = $mindeeClient->parse(BankCheckV1::class, $inputSource); // Print a brief summary of the parsed data echo strval($apiResponse->document);
Custom Document (API Builder)
use Mindee\Client; use Mindee\Product\Us\BankCheck\BankCheckV1; // Init a new client $mindeeClient = new Client("my-api-key"); // Load a file from disk $inputSource = $mindeeClient->sourceFromPath("/path/to/the/file.ext"); // Parse the file $apiResponse = $mindeeClient->parse(BankCheckV1::class, $inputSource); // Print a brief summary of the parsed data echo strval($apiResponse->document);
Full PDF support
Some features such as Invoice Splitter auto-extraction & Multi Receipts auto-extraction require the ImageMagick library, which in turn requires GhostScript.
Unix
ImageMagick is usually bundled with most installations. If not, you can install it using your distribution's package manager.
More details here.
Ghostscript can be installed from the website download page, or if using an apt compatible distribution:
sudo apt-get update sudo apt-get install -y ghostscript
In some cases, you might also want to authorize the ImageMagick policy to edit PDF files:
DQT='"' SRC="rights=${DQT}none${DQT} pattern=${DQT}PDF${DQT}" RPL="rights=${DQT}read|write${DQT} pattern=${DQT}PDF${DQT}" sudo sed -i "s/$SRC/$RPL/" /etc/ImageMagick-6/policy.xml
MacOS
Brew will be required for this install.
brew update
brew install imagemagick
pecl install imagick # Might not be needed in some instances. Do not try to install before installing PHP & Pecl.
Windows
You can install Ghostscript by downloading it, or simply by using Chocolatey.
choco install ghostscript --version 10.03.1 -y
⚠️ Important note if you are using Windows
The gs
alias might not be available by default, but it is possible to bind it fairly simply by either adding gswin32c.exe
or gswin64c.exe
to your $PATH
and then adding a symlink in powershell using:
New-Item -ItemType SymbolicLink -Path "C:\Windows\gs.exe" -Target "C:\Program Files\gs\gs10.03.1\bin\gswin64c.exe"
New-Item -ItemType SymbolicLink -Path "C:\Windows\gs" -Target "C:\Program Files\gs\gs10.03.1\bin\gswin64c.exe"
Further Reading
Complete details on the working of the library are available in the following guides:
- Getting started
- PHP Command Line Interface (CLI)
- PHP Generated APIs
- PHP Custom APIs (API Builder - Deprecated)
- PHP Invoice OCR
- PHP Receipt OCR
- PHP Financial Document OCR
- PHP Passport OCR
- PHP Resume OCR
- PHP Proof of Address OCR
- PHP International Id OCR
- PHP EU License Plate OCR
- PHP EU Driver License OCR
- PHP FR Bank Account Detail OCR
- PHP FR Carte Grise OCR
- PHP FR Carte Vitale OCR
- PHP FR ID Card OCR
- PHP US Bank Check OCR
- PHP US W9 OCR
- PHP US Driver License OCR
- PHP Barcode Reader API
- PHP Cropper API
- PHP Invoice Splitter API
- PHP Multi Receipts Detector API
You can view the source code on GitHub.
You can also take a look at the Reference Documentation.
License
Copyright © Mindee
Available as open source under the terms of the MIT License.