PHPackages                             serafim/ffi-sdl-mixer - 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. [Image &amp; Media](/categories/media)
4. /
5. serafim/ffi-sdl-mixer

ActiveLibrary[Image &amp; Media](/categories/media)

serafim/ffi-sdl-mixer
=====================

SDL Mixer FFI bindings for the PHP language

2.0.2(1y ago)1111MITCPHP ^8.1

Since Aug 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/SerafimArts/ffi-sdl-mixer)[ Packagist](https://packagist.org/packages/serafim/ffi-sdl-mixer)[ Docs](https://github.com/SerafimArts/ffi-sdl-mixer)[ RSS](/packages/serafim-ffi-sdl-mixer/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (14)Versions (4)Used By (0)

FFI SDL Mixer Bindings
======================

[](#ffi-sdl-mixer-bindings)

 [![PHP 8.1+](https://camo.githubusercontent.com/e801a0c2fbc7768e8ccb9b0839c263f5812a52475ad77812fb766ffe1f097424/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f6666692d73646c2d6d697865722f726571756972652f7068703f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/ffi-sdl-mixer) [![SDL_mixer](https://camo.githubusercontent.com/44a68e471c032fd1b4d8e8cdf21bae98c78e0d0e92f8f7faa15afb746dfdff1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53444c5f6d697865722d322e362e332d3133324234382e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d63253262253262)](https://github.com/libsdl-org/SDL_mixer) [![Latest Stable Version](https://camo.githubusercontent.com/2234cd961b5a5d6a544fb47908db483bee41d7d767f76ace006ed4681468b614/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f6666692d73646c2d6d697865722f76657273696f6e3f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/ffi-sdl-mixer) [![Latest Unstable Version](https://camo.githubusercontent.com/e25e8ebe99ed322ebeb26e6ebad668782e7988fd68e0de60fe80bdf29626c751/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f6666692d73646c2d6d697865722f762f756e737461626c653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/ffi-sdl-mixer) [![Total Downloads](https://camo.githubusercontent.com/ee563bc0d24519d61ce5056eb6671eedbaf6c71051091275b0c43882116bf819/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f6666692d73646c2d6d697865722f646f776e6c6f6164733f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/serafim/ffi-sdl-mixer) [![License MIT](https://camo.githubusercontent.com/5eca871da1d536eeba839a13ce4db84738445df39b99433ccbeb29f85ca4159c/68747470733a2f2f706f7365722e707567782e6f72672f7365726166696d2f6666692d73646c2d6d697865722f6c6963656e73653f7374796c653d666f722d7468652d6261646765)](https://raw.githubusercontent.com/serafim/ffi-sdl-mixer/master/LICENSE.md)

A SDL\_mixer extension FFI bindings for the PHP language compatible with [SDL FFI bindings for the PHP language](https://github.com/SerafimArts/ffi-sdl).

- [System Requirements](#requirements)
- [Installation](#installation)
- [Documentation](#documentation)
- [Initialization](#initialization)
- [Example](#example)

Requirements
------------

[](#requirements)

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

Installation
------------

[](#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](https://github.com/libsdl-org/SDL_mixer/releases)

Documentation
-------------

[](#documentation)

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

- [SDL2 Mixer official documentation](https://www.libsdl.org/projects/SDL_mixer/docs/index.html)

Initialization
--------------

[](#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
-------

[](#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();
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

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

Every ~240 days

Total

3

Last Release

577d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/150420?v=4)[Ruslan Sharipov](/maintainers/Serafim)[@serafim](https://github.com/serafim)

---

Tags

librarygraphicsaudioffibindingsmixeropenglsdl

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/serafim-ffi-sdl-mixer/health.svg)

```
[![Health](https://phpackages.com/badges/serafim-ffi-sdl-mixer/health.svg)](https://phpackages.com/packages/serafim-ffi-sdl-mixer)
```

###  Alternatives

[serafim/ffi-sdl

SDL FFI bindings for the PHP language

324.6k3](/packages/serafim-ffi-sdl)[imagine/imagine

Image processing for PHP

4.5k75.7M397](/packages/imagine-imagine)[php-ffmpeg/php-ffmpeg

FFMpeg PHP, an Object Oriented library to communicate with AVconv / ffmpeg

5.0k24.0M194](/packages/php-ffmpeg-php-ffmpeg)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[nutgram/nutgram

The Telegram bot library that doesn't drive you nuts

737290.3k8](/packages/nutgram-nutgram)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)

PHPackages © 2026

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