https://github.com/ponup/php-sdl
SDL2 bindings for the PHP language
https://github.com/ponup/php-sdl
c hacktoberfest php sdl
Last synced: 8 months ago
JSON representation
SDL2 bindings for the PHP language
- Host: GitHub
- URL: https://github.com/ponup/php-sdl
- Owner: Ponup
- License: mit
- Created: 2013-12-04T13:02:26.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2023-08-06T21:14:15.000Z (over 2 years ago)
- Last Synced: 2025-03-31T01:51:18.316Z (9 months ago)
- Topics: c, hacktoberfest, php, sdl
- Language: C
- Homepage: https://pecl.php.net/package/sdl
- Size: 689 KB
- Stars: 110
- Watchers: 9
- Forks: 22
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/Ponup/php-sdl/actions/workflows/build-test.yml)
PHP-SDL
=======
SDL (Simple DirectMedia Layer) bindings for the PHP language. The extension allows you to create multimedia desktop applications with windows, input handling, events, and more.
[
](input-handling-example.gif)
## Installation
### Requirements
* C compiler
* Automake tools
* PHP8.1 devel
* libSDL2 devel libraries and headers
* UN*X OS (eg Linux, Macos)
### Via PECL
```bash
pecl install sdl-beta
```
Then add
```
extension=sdl.so
```
to your _php.ini_ file.
> If you have no idea about your ini file position you can run `php -i | grep ini` and see the list of you ini files.
## Documentation
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](https://wiki.libsdl.org/APIByCategory).
## Examples
Standard SDL2 API is available in procedural style:
```php
$window = SDL_CreateWindow( "Foo window", 500, 50, 350, 300, SDL_WINDOW_SHOWN+SDL_WINDOW_RESIZABLE);
SDL_SetWindowTitle($window, "Some new title");
SDL_DestroyWindow($window);
```
Complete examples can be found in the [examples](examples) folder.
## Related projects
* [PHP-SDL_TTF](https://github.com/Ponup/php-sdl-ttf)
* [PHP-SDL_Mixer](https://github.com/kea/php-sdl-mixer)
* [PHP-SDL_Image](https://github.com/kea/php-sdl-image)
* [PHP-OpenGL](https://github.com/ponup/php-opengl)
* [PHP-OpenAL](https://github.com/Ponup/php-openal)
## Projects using the extension
* [CubeCraft](https://github.com/Ponup/cubecraft)
* [Conway's game of life](https://github.com/Ponup/conways-game-of-life)
* [PhpOkoban](https://github.com/b-viguier/PhpOkoban)
* [Inphpinity](https://github.com/b-viguier/Inphpinity)
* [PhPresent](https://github.com/b-viguier/PhPresent)
## Building
To compile your new extension, you will have to execute the following steps:
```bash
phpize
./configure [--with--sdl]
make
make test
sudo make install
```