1. Go to this page and download the library: Download andileco/php-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/ */
andileco / php-epub example snippets
use PhpEpub\Epub;
use PhpEpub\Metadata;
use PhpEpub\Chapter;
use PhpEpub\Resource;
use PhpEpub\Semantic;
$epub = Epub::create()
->metadata(
Metadata::create('My Book')
->authors(['Jane Doe'])
->isbn('978-1234567890')
->publisher('Example Press')
)
->stylesheet(Resource::fromFile('styles.css'))
->chapter(
Chapter::create('Introduction', '<h1>Introduction</h1><p>Welcome.</p>')
->semantic(Semantic::INTRODUCTION)
)
->chapter(
Chapter::create('Chapter 1', '<h1>Getting Started</h1><p>Content here...</p>')
->semantic(Semantic::CHAPTER)
->subChapter(
Chapter::create('Prerequisites', '<h2>Prerequisites</h2><p>You need...</p>')
)
)
->save('my-book.epub');
// From file
->resource(Resource::fromFile('/path/to/image.jpg', 'images/photo.jpg'))
// From string
->resource(Resource::fromString($svgData, 'images/chart.svg'))