snordian/h5p-extractor
Composer 安装命令:
composer require snordian/h5p-extractor
包简介
Allows to create H5P content HTML server-side
关键字:
README 文档
README
Tool that is supposed to be be usable for rendering H5P content server-side.
Quick start (to be done properly (!))
-
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.jsonfile 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.
-
Use
require_once <path_to_h5p-extractor> . '/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. -
Use
$h5pExtractor = new H5PExtractor\H5PExtractor($config);to create an instance, where$configis supposed to be an optional an associative array containing configuration items, e.g.:$config = [ 'uploadsPath' => <path to be used for uploads relative to h5p-extractor : string> 'renderWidth' => <the assumed viewport width : number, default: 1024> 'renderWidths' => [ '<machineName: string>' => <the assumed viewport width : number>, ] 'target' => <specific target as option : ['print|screen'], default: 'print'> 'scope' => <specific scope as option : ['all|initial'], default: 'all'> 'customCssPre' => <custom CSS to be applied before H5P core/content CSS is set : string> 'customCssPost' => <custom CSS to be applied after H5P core/content CSS is set : string> 'h5pCoreUrl' => <full URL to `h5p-php-library/` folder to use as core asset source : string> 'h5pLibrariesUrl' => <full URL to `libraries/` folder to use as content type asset source : string> 'h5pContentUrl' => <full URL to `content/<id>/` folder to use author defined content as source> 'solutionStyle' => <how to format the solution : ['reversed'], default: null> ]By default, if that value is not set or no
$configargument is passed, H5PExtractor will- try to create/use a directory named
uploadsinside its mainh5p-extractordirectory, - 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,
- return solutions unmodified if no
solutionStyleis set.
Please ensure that the respective
uploadsdirectory can be read and written by your server process. - try to create/use a directory named
-
Use something like
$extract = $h5pExtractor->extract( [ 'file' => $file['tmp_name'], 'format' => $_POST['format'] ] );where
fileis 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.formatspecifies the desired output format (currentlyhtml(default) ortext) - here theformatkey of the form upload.
The return value is an associative array with the key
resultorerror.resultcontains the requested output formaterrorcontains an error message if something went wrong.
Creating/changing 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 Generator
TODO: Explain GeneratorInterface
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.
snordian/h5p-extractor 适用场景与选型建议
snordian/h5p-extractor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.34k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2025 年 09 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「h5p」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 snordian/h5p-extractor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 snordian/h5p-extractor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 snordian/h5p-extractor 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Create and add rich content to your website for free. Some examples of what you get with H5P are Interactive Video, Quizzes, Collage and Timeline.
H5P Bundle for Symfony 5, 6 and Symfony 7
H5P Editor functionality in PHP
H5P Platform Integration Plugin for Neos CMS
H5P Core functionality in PHP
H5P Core functionality in PHP
统计信息
- 总下载量: 11.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-26