定制 scottboms/kirby-applemusic 二次开发

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

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

scottboms/kirby-applemusic

Composer 安装命令:

composer require scottboms/kirby-applemusic

包简介

Apple Music plugin for Kirby

README 文档

README

Plugin Preview

Adds Field and Block types for Apple Music including a live preview of embeds in the panel. Version 2.0.0 introduces an optional Panel Area that integrates with the Apple Music API (requires a paid Apple Developer account) to display recently played songs using an authenticated Apple Music account. Results provide quick access to copy a song's URL and embed code. Recently played songs can also be exposed to templates using a provided snippet.

Installation

Kirby CLI

kirby plugin:install scottboms/kirby-applemusic

Git submodule

git submodule add https://github.com/scottboms/kirby-applemusic.git site/plugins/kirby-applemusic

Copy and Paste

  1. Download the contents of this repository as Zip file.
  2. Rename the extracted folder to kirby-applemusic and copy it into the site/plugins/ directory in your Kirby project.

Configuration Options

An optional configuration setting can be set to override the default format for the field.

Property Default Req? Description
scottboms.applemusic.format link No Sets the field type format - link or embed

Example Use (in config/config.php):

return [
  scottboms.applemusic.format => 'embed'
]

If using the Apple Music API, you will first need to generate the necessary keys and p8 token. Those values can then be added to your site config which will allow access from the Panel and also to your templates.

Required:

These private properties should be stored securely outside version control systems. This can be done by creating an env.php file in the site/config folder and adding that to your .gitignore rules.

Property Default Req? Description
teamId null Yes Available from Apple Developer account profile
keyId null Yes A generated Apple Music Media ID Key
privateKey null Yes The raw contents of the generated .p8 token
allowedOrigins null No An array of domains to allow for handling CORS responses

Example Use (in config/env.php):

return [
  // private plugin config
  'scottboms.applemusic' => [
    'teamId' => 'ABCDE12345',
    'keyId' => '1A2BC3DEFG',
    'privateKey' => '-----BEGIN PRIVATE KEY-----///-----END PRIVATE KEY-----',
    'allowedOrigins' => [
      'https://example.com', 'https://yoursite.com'
    ],
  ],
]

Optional Config Overrides:

Property Default Req? Description
tokenTtl 3600 No Length of time token persists in seconds (6 min)
tokenCacheTtlMinutes 43200 No Length of time for tokenCache to persist (30 days)
songsLimit 15 No The number of songs to show in the Panel Area
songsToShow 12 No The number of songs to show via the included snippet

Example Use (in config/config.php):

return [
  // applemusic plugin config
  'scottboms.applemusic' => [
    'tokenTtl' => 4800,
    'songsLimit' => 10,
    'songsToShow' => 6
  ],
]

Cache Settings:

Turn on file caching for the plugin using:

return [
	cache => [
		'scottboms.applemusic' => [
			'type' => 'file',
		]
	],
]

Usage

Blueprints

In a Page blueprint, add a new field with the type applemusic. Standard field attributes such as label, required, help, etc. can also be used to override the defaults. Use emptyText to change the default text displayed when the field is in an empty state.

  music:
    label: Apple Music Embed
    type: applemusic
    emptyText: 'Click to paste Apple Music embed code'

  blocks:
    type: blocks
    fieldsets:
      - heading
      - text
      - image
      - applemusic

Templates and Snippets

If using the defaults, and based on the example Blueprint above, to render the field in your template you can use <?= $page->music() ?>. Note that any additional helper functions applied may break the embed. You do not need to use ->kt() or ->kti() for example.

If using the link format, a custom snippet is included to handle formatting the link into a properly formatted <iframe> embed. For example:

<?php snippet('applemusic', ['field' => $page->music()]) ?>

If using the API, a snippet is included to handle displaying a customizable grid of recent songs.

<?= snippet('recently-played', ['limit' => 6]) ?>

Compatibility

  • Kirby 4.x
  • Kirby 5.x

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test before using it in a production environment. If you identify an issue, typo, etc, please create a new issue so I can investigate.

License

MIT

scottboms/kirby-applemusic 适用场景与选型建议

scottboms/kirby-applemusic 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 08 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 scottboms/kirby-applemusic 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-06