PHP OCR SDK
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);
Further Reading
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.
Updated 4 days ago