vaites / php-apache-tika

Apache Tika bindings for PHP: extract text and metadata from documents, images and other formats
MIT License
114 stars 22 forks source link

Vaites apache tika with Xampp Stack Windows enviornment. #19

Closed GAMESTER90 closed 5 years ago

GAMESTER90 commented 5 years ago

Hey so this is not really an issue per say more like a solution, I see that #10 recently added some windows compatibility but for me noting that I have not worked that much with php came across a bug where I would get "Java command not found" from a conditional statement within a conditional in 'vendor/vaites/php-apache-tika/src/clients/CLIClient.php' on line 121, vaites apache tika version 1.20 and my solution for this was changing the exec string

exec(($this->java ?: 'java') . ' -version 2> /dev/null', $output, $return); if($return != 0) { throw new Exception('Java command not found'); } to this, exec(($this->java ?: 'java') . ' -version', $output, $return); if($return != 0) { throw new Exception('Java command not found'); }

it seems to me that the command it is using is to call within a Linux environment, excuse my lack of technical terminology, and since java is installed globally on my windows 10 machine there is no need so I simply delete the path string at the end and my $client variable get's properly initialized when the CLIClient is constructed/instantiated.

I share this as minor and insignificant detail as it may be because I think others may find use in it, or in the hope that this inconvenience may be resolved in the future, thanks for your attention. :D

vaites commented 5 years ago

Thanks @GAMESTER90, you're right. The command must be executed without the 2> /dev/null used only on Unix. Will fix soon.