定制 surface/commonmark-ext-youtube-iframe 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

surface/commonmark-ext-youtube-iframe

Composer 安装命令:

composer require surface/commonmark-ext-youtube-iframe

包简介

Extension for league/commonmark to replace YouTube link with an iframe.

README 文档

README

An extension for league/commonmark version 2 built using PHP 8.0. This replaces YouTube links with the embed iframe.

The extension supports for the primary YouTube URL, with and without prefixed with the www. It also supports the short shareable URL using the youtu.be domain.

Initially based on the YouTube extension.

Installation

The project should be installed via Composer:

composer require surface/commonmark-ext-youtube-iframe

Usage

Configure your CommonMark Environment and add the extension.

use League\CommonMark\Environment\Environment;
use League\CommonMark\MarkdownConverter as Converter;
use Surface\CommonMark\Ext\YouTubeIframe\Extension as YouTubeExtension;

$options = [
    'youtube_iframe' => [
        'width' => 800,
        'height' => 600,
    ]
];

$environment = new Environment($options);
$environment->addExtension(new YouTubeExtension());

$converter = new Converter($environment);

echo $converter->convert('[](https://youtu.be/xxx)');
echo $converter->convert('[](https://www.youtube.com/watch?v=xxx)');
echo $converter->convert('[](https://youtu.be/xxx?height=480)');
echo $converter->convert('[](https://www.youtube.com/watch?v=xxx&width=640)');

Dimensions

You can control the dimensions of the videos by using the width and height configuration options.

You can also configure the dimensions using query parameters on the embed URL. You can provide the height or width or both.

?width=640
?height=480
?width=640&height=480

Full URL

You can disable the parsing of full YouTube URLs (with or without the www) by using the following option. If this option is disabled, only URLs under the ‘short’ domain will be used (youtu.be).

$options = [
    'youtube_iframe' => [
        'full_url' => false,
    ]
];

Testing

There are Unit and Integration tests for the project. These can be run using the following commands:

composer test
composer run test
composer run test-unit
composer run test-integration

There are also scripts to run code sniffer, mess detector and static analysis:

composer run sniff
composer run mess
composer run stan

Changelog

Please refer to the CHANGELOG for more information on what has changed recently.

License

This library is licensed under the MIT license. See the License File for more information.

surface/commonmark-ext-youtube-iframe 适用场景与选型建议

surface/commonmark-ext-youtube-iframe 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.02k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 05 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「markdown」 「extension」 「youtube」 「iframe」 「music」 「embed」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 surface/commonmark-ext-youtube-iframe 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 surface/commonmark-ext-youtube-iframe 我们能提供哪些服务?
定制开发 / 二次开发

基于 surface/commonmark-ext-youtube-iframe 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.02k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 26
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-13