PHP code example of tregor / epub

1. Go to this page and download the library: Download tregor/epub 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/ */

    

tregor / epub example snippets


use tregor\epub\EPubBook;

$book = new EPubBook('My First Book');

$book = EPubBook::open('existing_book.epub');

$book->setAuthor('John Doe');
$book->setLanguage('en');

$book->addChapter('Chapter 1', 'This is the first chapter.', 1);
$book->addChapter('Chapter 2', 'This is the second chapter.', 2);

$book->addChapterAfter(1, 'Chapter 2', 'This is the new Chapter 2.', 2);

$book->removeChapter(2);

$book->setChapterContent(1, 'This is the updated content of Chapter 1.');

$book->export('my_first_book.epub');