承接 serafim/ffi-sdl-mixer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

serafim/ffi-sdl-mixer

Composer 安装命令:

composer require serafim/ffi-sdl-mixer

包简介

SDL Mixer FFI bindings for the PHP language

README 文档

README

PHP 8.1+ SDL_mixer Latest Stable Version Latest Unstable Version Total Downloads License MIT

A SDL_mixer extension FFI bindings for the PHP language compatible with SDL FFI bindings for the PHP language.

Requirements

  • PHP ^8.1
  • ext-ffi
  • Windows, Linux, BSD or MacOS
    • Android, iOS or something else are not supported yet
  • SDL and SDL Mixer >= 2.0

Installation

Library is available as composer repository and can be installed using the following command in a root of your project.

$ composer require serafim/ffi-sdl-mixer

Additional dependencies:

  • Debian-based Linux: sudo apt install libsdl2-mixer-2.0-0 -y
  • MacOS: brew install sdl2_mixer
  • Window: Can be downloaded from here

Documentation

The library API completely supports and repeats the analogue in the C language.

Initialization

In the case that you need a specific SDL instance, it should be passed explicitly:

$sdl = new Serafim\SDL\SDL(version: '2.28.3');
$mixer = new Serafim\SDL\Mixer\Mixer(sdl: $sdl);

// If no argument is passed, the latest initialized
// version will be used.
$mixer = new Serafim\SDL\Mixer\Mixer(sdl: null);

! It is recommended to always specify the SDL dependency explicitly.

To specify a library pathname explicitly, you can add the library argument to the Serafim\SDL\Mixer\Mixer constructor.

By default, the library will try to resolve the binary's pathname automatically.

// Load library from pathname (it may be relative or part of system-dependent path)
$mixer = new Serafim\SDL\Mixer\Mixer(library: __DIR__ . '/path/to/library.so');

// Try to automatically resolve library's pathname
$mixer = new Serafim\SDL\Mixer\Mixer(library: null);

You can also specify the library version explicitly. Depending on this version, the corresponding functions of the SDL Image will be available.

By default, the library will try to resolve SDL Image version automatically.

// Use v2.0.5 from string
$mixer = new Serafim\SDL\Mixer\Mixer(version: '2.0.5');

// Use v2.6.3 from predefined versions constant
$mixer = new Serafim\SDL\Mixer\Mixer(version: \Serafim\SDL\Mixer\Version::V2_6_3);

// Use latest supported version
$mixer = new Serafim\SDL\Mixer\Mixer(version: \Serafim\SDL\Mixer\Version::LATEST);

To speed up the header compiler, you can use any PSR-16 compatible cache driver.

$mixer = new Serafim\SDL\Mixer\Mixer(cache: new Psr16Cache(...));

In addition, you can control other preprocessor directives explicitly:

$pre = new \FFI\Preprocessor\Preprocessor();
$pre->define('true', 'false'); // happy debugging!

$mixer = new Serafim\SDL\Mixer\Mixer(pre: $pre);

Example

use Serafim\SDL\SDL;
use Serafim\SDL\Mixer\Mixer;

$sdl = new SDL();
$mixer = new Mixer(sdl: $sdl);

$sdl->SDL_Init(\Serafim\SDL\InitFlags::SDL_INIT_EVERYTHING);
$mixer->Mix_Init(\Serafim\SDL\Mixer\InitFlags::MIX_INIT_MP3);

$mixer->Mix_OpenAudio(44100, SDL::AUDIO_S16SYS, 2, 2048);
$music = $mixer->Mix_LoadMUS(__DIR__ . '/example.mp3');
$mixer->Mix_PlayMusic($music, 0);

while (true) {
    usleep(1);
}

$mixer->Mix_Quit();
$sdl->SDL_Quit();

serafim/ffi-sdl-mixer 适用场景与选型建议

serafim/ffi-sdl-mixer 是一款 基于 C 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 08 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 serafim/ffi-sdl-mixer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: C

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-12