Install composer (globaly is better)
wget http://getcomposer.org/composer.phar
mv composer.phar /usr/bin/composer
Add vibby/epub
to your dependencies
composer require vibby/epub
$reader = new \Vibby\EPub\Reader\Reader();
$ePub = $reader->load($fileName);
printf("Title: %s\n", $epub->getMetadata()->getValue('title'));
$firstChapter = $ePub->getPackage()->getSpine()->get(0);
$content = $firstChapter->getContent();
// manipulate HTML here
$ePub->updateChapterContent($firstChapter, $content);
Built on the base of https://github.com/justinrainbow/epub