PHPackages                             snordian/h5p-extractor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. snordian/h5p-extractor

ActiveLibrary

snordian/h5p-extractor
======================

Allows to create H5P content HTML server-side

0.4.1(5mo ago)66.6k↓78.6%1[1 PRs](https://github.com/otacke/H5PExtractor/pulls)MITPHP

Since Oct 3Pushed 2d ago1 watchersCompare

[ Source](https://github.com/otacke/H5PExtractor)[ Packagist](https://packagist.org/packages/snordian/h5p-extractor)[ RSS](/packages/snordian-h5p-extractor/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

H5P Extractor - proof of concept
================================

[](#h5p-extractor---proof-of-concept)

Tool that is supposed to be be usable for rendering H5P content server-side.

VERY IMPORTANT NOTE
-------------------

[](#very-important-note)

The H5PExtractor library needs to ship with H5P core as a dependency. See . As of writing 1.26 is the latest version that has been released, but the H5P plugin for WordPress had not received proper attention for a long time, and used and required 1.24. API changes from 1.24 to 1.26 were not implemented in the WordPress plugin until plugin version 1.16.

When H5PExtractor is used, it will reference H5P core 1.26 which will cause trouble if you are still using the H5P plugin in a version prior to 1.16.

In consequence, if you want to use H5PExtractor, you should update the H5P plugin for WordPress to version 1.16 at least or pin the h5p-core dependency in composer.json to 1.24.4 by changing `"h5p/h5p-core": "^1.26.0"` to `"h5p/h5p-core": "1.24.4"`. If you do the latter, make sure to remember to change the dependency when you ultimately update the H5P plugin for WordPress.

Quick start (to be done properly (!))
-------------------------------------

[](#quick-start-to-be-done-properly-)

1. Copy the library to your ow project. You can also use composer, but you will need to fetch the library from github, because it is not available via packagist (yet).

    Your `composer.json` file should contain

    ```
    "repositories": [
         {
             "type": "vcs",
             "url": "https://github.com/otacke/H5PExtractor"
         }
     ],
     "require": {
         "snordian/h5p-extractor": "dev-master"
    }

    ```

    and any other of your dependencies, of course.
2. Use `require_once  . '/app/H5PExtractor.php';` to load code. It does autload everything it needs, but it is not instantiated by any autoload itself, because it it seems appropriate to only load H5PExtractor once actually needed.
3. Use `$h5pExtractor = new H5PExtractor\H5PExtractor($config);` to create an instance, where `$config` is supposed to be an optional an associative array containing configuration items, e.g.:

    ```
    $config = [
      'uploadsPath' =>
      'renderWidth' =>
      'renderWidths' => [
       '' => ,
      ]
      'target' =>
      'scope' =>
      'customCssPre' =>
      'customCssPost' =>
      'h5pCoreUrl' =>
      'h5pLibrariesUrl' =>
      'h5pContentUrl' =>
    ]

    ```

    By default, if that value is not set or no `$config` argument is passed, H5PExtractor will

    - try to create/use a directory named `uploads` inside its main `h5p-extractor` directory,
    - use a default render width of 1024 pixels,
    - use the default or set render width if no machineName specific render width was set for a particular content type,
    - not apply and custom CSS,
    - return base64 encoded representations of files inside the file if no Url to core, libraries or the content is set.

    Please ensure that the respective `uploads` directory can be read and written by your server process.
4. Use something like

    ```
    $extract = $h5pExtractor->extract(
        [
            'file' => $file['tmp_name'],
            'format' => $_POST['format']
        ]
    );

    ```

    where

    - `file` is supposed to be the H5P file that contains the H5P content that is supposed to be rendered - here a standard temporary file generated by a form upload.
    - `format` specifies the desired output format (currently `html` (default) or `text`) - here the `format` key of the form upload.

    The return value is an associative array with the key `result` or `error`.

    - `result` contains the requested output format
    - `error` contains an error message if something went wrong.

Creating/changing generators
----------------------------

[](#creatingchanging-generators)

A generator is what creates a distinct output format from an H5P content. It will commonly be HTML or some plain text variant, but could be something different, too.

The generation process resembles how the H5P core composes H5P content from different content types, and methods such as `newRunnable` or `attach` were called that way because they have direct counterparts in H5P core/a content type. They also use the same arguments, even though they're not all required here. If you know `newRunnable` or `attach`, then you already know what they do here. And if you don't and learn what they do here, you learn something about H5P core and H5P content types as a side product :-)

### TODO: Explain Structure

[](#todo-explain-structure)

### TODO: Explain Generator

[](#todo-explain-generator)

### TODO: Explain GeneratorInterface

[](#todo-explain-generatorinterface)

### Open issues:

[](#open-issues)

- Implement handling of target and scope where needed
- Add option to display answers for questions
- Support H5P theming scheduled to be released late in 2025.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance87

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

171d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/40d335f55bc5365ef7691f97568fe114e29dffb9581b9a635139330ccc6cd2bc?d=identicon)[otacke](/maintainers/otacke)

---

Top Contributors

[![otacke](https://avatars.githubusercontent.com/u/16688047?v=4)](https://github.com/otacke "otacke (227 commits)")

---

Tags

h5p

### Embed Badge

![Health badge](/badges/snordian-h5p-extractor/health.svg)

```
[![Health](https://phpackages.com/badges/snordian-h5p-extractor/health.svg)](https://phpackages.com/packages/snordian-h5p-extractor)
```

###  Alternatives

[h5p/h5p-core

H5P Core functionality in PHP

1401.4M25](/packages/h5p-h5p-core)[h5p/h5p-editor

H5P Editor functionality in PHP

761.4M23](/packages/h5p-h5p-editor)[jorisdugue/h5p-bundle

H5P Bundle for Symfony 5, 6 and Symfony 7

1131.6k](/packages/jorisdugue-h5p-bundle)[escolalms/headless-h5p

Headless H5P Laravel REST API

2731.7k2](/packages/escolalms-headless-h5p)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
