承接 dmvdbrugge/epub-builder 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dmvdbrugge/epub-builder

最新稳定版本:v0.1.2

Composer 安装命令:

composer require dmvdbrugge/epub-builder

包简介

Package to help you build EPUB files from your own content.

README 文档

README

Easily transform your own content into EPUB files for reading on ereaders and book apps.

Basic Usage

// 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 required but should be valid when provided
    ->identifier("my-awesome-website.com:book:9371") // Optional when ISBN provided
    ->language("en") // IETF language tag
    ->modified($lastModified)
    ->publisher("My Awesome Website")
    ->title("Life Stories to Learn From; or Not.")
    ->chapters($chapters)
    ->build();

// Step 3: Save somewhere...
copy($epub->getFileOnDisk(), "/home/user/books/{$epub->getFileName()}");

// ...or offer as download
// - Example 1: direct output
foreach ($epub->getHttpHeaders() as $header => $value) {
    header("{$header}: {$value}");
}

readfile($epub->getFileOnDisk());

// - Example 2: PSR-7 (f.e. Slim, $response exists)
foreach ($epub->getHttpHeaders() as $header => $value) {
    $response = $response->withHeader($header, $value);
}

$response = $response->withBody(new \Slim\Psr7\Stream($epub->getFileHandle()));

// Step 4: Go read your new EPUB

Installation and Requirements

Installation is just a composer call away.

composer require dmvdbrugge/epub-builder

Notable requirements: ext-zip, in the future probably also ext-simplexml to ensure valid xhtml.
As with any composer project, composer.json has the full requirements.

Documentation

Full documentation, among other things, is still TODO.

License

MIT License

Copyright (c) 2024 Dave van der Brugge

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-12