PHP Classes
elePHPant
Icontem

PHP Kindle Periodical: Generate Kindle ebook file in .mobi format

Recommend this page to a friend!
  Info   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2013-09-02 (3 years ago) RSS 2.0 feedNot enough user ratingsTotal: 382 All time: 6,407 This week: 802Up
Version License PHP version Categories
kindle-periodical 1.0Free for non-comm...5.1.0PHP 5, Files and Folders, Content man...
Description Author

This class can generate Kindle ebook file in .mobi format.

It takes an array with the definition of the content sections and generates temporary ebook definition files using HTML templates, as well a .mobi file in a given directory using the kindlegen program.

The class may redirect the browser to a URL to download the Kindle .mobi file, as well cleanup any temporary files.

Innovation Award
PHP Programming Innovation award nominee
August 2013
Number 2


Prize: One downloadable e-book of choice by O'Reilly
Kindle is a popular e-reader device and ebook publishing platform.

This class helps generating ebooks in the .mobi format that can be read using the Kindle application. It uses HTML templates as base for the generated ebooks.

Manuel Lemos
Name: Sergio Vilar <contact>
Classes: 1 package by
Country: Brazil Brazil
Age: 25
All time rank: 3392268 in Brazil Brazil
Week rank: 1122 Up90 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 1x

Details
Kindle Periodical
=================

Php class that helps to build kindle periodicals

**Important:** You need to add [KindleGen](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211) to your path to run KindlePeriodical

## Usage

First you need to create an array with the content of the periodical:

	$content = array(
		
		// Array of sections
		array(
			'id' => '0',
			'name' => 'My first section',
			'content' => array(

				// Array of articles
				array(
					'title' => 'Title of my first article',
					'content' => 'content of my article' // HTML is allowed
				)
			)
		),
		
		array(
			'id' => '1',
			'name' => 'My toher section',
			'content' => array(

				// Array of articles
				array(
					'title' => 'Title of my other article',
					'content' => 'content of my article'
				)
			)
		)


	);
	
With this, you can now generate your .mobi file with KindlePeriodical:

     $ebook = new \Kindle\Periodical(array(
        
        "outputFolder" => "out",
        
        // Optional arguments:
        "shell" => false, // KindlePeriodical will use exec instead of shell_exec
        "debug" => true

    ));

    $ebook->setMeta(array(
        'title' => 'My Kindle Periodical',
        'creator' => "sergiovilar",
        'publisher' => "sergiovilar",
        'subject' => 'Sample Periodical',
        'description' => 'Set of articles in one .mobi file'
    ));

    // Generates the file
    $content = $ebook->setContent($content);

    // Return the file name
    $file = $ebook->getFilename();

    // Download the file
    $ebook->downloadFile();

    // Remove the file and directory
    $ebook->deleteFile();
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file, 1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Data Auxiliary data
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imagetpl (6 files)
  Plain text file KindlePeriodical.php Class Class source

  Files folder image Files  /  src  /  tpl  
File Role Description
  Accessible without login HTML file article.html Data Auxiliary data
  Accessible without login HTML file article_ncx.html Doc. Documentation
  Accessible without login HTML file contents.html Data Auxiliary data
  Accessible without login HTML file content_opf.html Data Auxiliary data
  Accessible without login HTML file nav-contents_ncx.html Data Auxiliary data
  Accessible without login HTML file section_ncx.html Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:382
This week:0
All time:6,407
This week:802Up