PHP code example of errogaht / yandex-ocr-php

1. Go to this page and download the library: Download errogaht/yandex-ocr-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

errogaht / yandex-ocr-php example snippets


// can pass optional arguments: $langFrom, $langTo, API $url
$client = new \Errogaht\YandexOCR\Client();

//tell path to recognizing file
$client->setFilePath(__DIR__ . '/1e741d3b-ba67-42e5-8229-f07a72072c96.png');

//get response from Yandex translate
$response = $client->request();

//convert response to plain text
$texter = new \Errogaht\YandexOCR\Response2Text($response);
$text = $texter->getText();