If you don't refuse REST API, then you can use:
- Apache Tika. Is a proven OSS leader for text-extraction
- If you don't want to hassle with configuring and want ready-to-go solution you can use RawText, but it's not free.
Sample code for RawText:
$result = $rawText -> parse($your_file)