thiagoalessio / tesseract-ocr-for-php

A wrapper to work with Tesseract OCR inside PHP.
https://packagist.org/packages/thiagoalessio/tesseract_ocr
MIT License
2.87k stars 551 forks source link

Better error message when `system` and/or `exec` functions are disabled #168

Open thiagoalessio opened 5 years ago

thiagoalessio commented 5 years ago

Expected behavior

Present a clear error message to users if environment has disabled system and/or exec builtin PHP functions, and interrupt the execution before attempting to use such disabled functions.

Actual behavior

Right now nothing stops the execution, and it fails much later with a "Command did not produce any output" exception. Only warnings are shown:

<b>Warning</b>:  system() has been disabled for security reasons in ...
<b>Warning</b>:  exec() has been disabled for security reasons in ...

Steps to reproduce the behavior

  1. Disable system and/or exec in php.ini https://www.php.net/manual/en/ini.core.php#ini.disable-functions
  2. Try to run any TesseractOCR example.

Environment

ThomasLandauer commented 2 years ago

Maybe you could also add some nice method to check if tesseract is installed at all. When (mis)using $ocr->version() for this, I'm getting 1: if it's not installed - probably some artifact of the exploding that's done at Command::getTesseractVersion()