Skip to content
SDL2 bindings for the PHP language
C C++ PHP Other
Branch: master
Clone or download

Build Status


SDL (Simple DirectMedia Layer) bindings for the PHP language.



  • C compiler
  • Automake tools
  • PHP devel
  • libSDL2 devel libraries and headers
  • UN*X OS (eg Linux, Macos)


pecl install sdl-devel

Then add

to your php.ini file.


The SDL extension mimics in almost every single aspect to the official C library, so until we write our own documentation, refer to the C counterpart.


Standard SDL2 API is available in procedural style:

    $window = SDL_CreateWindow( "Foo window", 500, 50, 350, 300, SDL_WINDOW_SHOWN+SDL_WINDOW_RESIZABLE);
    SDL_SetWindowTitle($window, "Some new title");

And is also available in object oriented style:

    $window = new SDL_Window( "Foo window", 100, 50, 350, 300, SDL_Window::SHOWN|SDL_Window::RESIZABLE);
    $window->SetTitle("Some new title");
    unset($window); // will destroy the window


To compile your new extension, you will have to execute the following steps:

$ phpize
$ ./configure [--enable--sdl] 
$ make
$ make test
$ [sudo] make install

Support and feature requests

Please submit anything that needs our attention to issues section on Github. We are commited to attend any request in a short timespan if it's a sensible matter.

Projects using this extension

You can’t perform that action at this time.