PHP code example of dmvdbrugge / epub-builder

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

    

dmvdbrugge / epub-builder example snippets


// Step 1: Get your data from somewhere
$chapters = [
    // Title => Content; Content can be anything, as long as it's valid xhtml when added to a <body>
    "The Early Years" => "<h1>The Early Years</h1><p>I was youg and naive (...)"
        . "and that's how I ended up with my best friend.</p>",
    "The One that Got Away" => "<h1>The One that Got Away</h1><p>A lot of people have one,"
        . "(...) I still wonder sometimes, what if...</p>",
    "Death and After" => "<h1>Death and After</h1><p>When I die (...) and that's that.</p>",
];

$lastModified = \DateTimeImmutable::createFromFormat(DATE_ATOM, "2024-09-16T05:31:42+02:00");

// Step 2: Pass your data into an EpubBuilder and ->build() it
$epub = (new \DMvdBrugge\EpubBuilder\EpubBuilder())
    ->author("Me! Or You!")
    ->description("Life Stories to Learn From; or Not. You decide! This is the story of my life.")
    ->isbn("0-553-10354-7") // Not