GameDev and Real-Time Applications in PHP

Make games in PHP! Or create real-time visualizations! Or design your own GUI library!
PHP-GLFW brings 2D and 3D rendering capabilities to PHP.

Getting Started

Batteries included 🔋

To create interactive applications, you need more than just GLFW bindings. This extension aims to provide you with all the basic tools necessary to develop interactive, real-time applications in PHP.

  • GLFW Bindings

    The obvious one, this extension contains almost full support for GLFW, which provides a simple API for creating windows, contexts, and surfaces, as well as for handling input and system events.

  • Cross-Platform

    PHP-GFLW works on Window, MacOS and Linux. We also support standalone & portable binaries for MacOS and Windows.

  • HTML Canvas like API

    Just want to get something onto the screen quickly without having to deal with shaders, vertices, and lots of boilerplate? PHP-GLFW supports a Vector Graphics API for drawing simple graphics with minimal effort.

  • OpenGL Bindings

    Full native support for OpenGL (4.1+ core), bringing GPU-accelerated rendering to PHP. We currently support approximately 90% of the full standard.

  • Math Library

    PHP-GLFW comes with a built-in mathematics library, written in C and optimized for graphical applications. It includes common structs like Vec3, Vec4, Mat4, etc., and many operations you usually find in graphical applications like lookAt, distance, etc.

  • Many Utilities

    Need to load an image as a texture or a 3D model? We don't leave you hanging; PHP-GLFW contains many utilities for your GameDev or application needs.

Go 3D with PHP

Hey that rhymes!

Step into 3D programming with PHP-GLFW, bridging PHP with the amazing power and simplicity of OpenGL.

We try hard to keep the API as close as possible to its C counterpart, which has a few benefits.

  • There is an ocean of OpenGL tutorials and guides out there, and these are almost identically applicable when using this extension.
  • We do not predetermine how the rendering pipeline works, thus providing you with full and granular control over the rendering process.

Make 2D Games

While PHP-GLFW shines in 3D rendering, it's equally adept in flatland aka in 2D space. We made FlappyPHPant, our PHP-powered tribute to Flappy Bird.

Check it out

Vector Graphics API

Sometimes, you just want something simple...

We have a ton of Interactive Examples for the Vector Graphics API as it is just fun to create things with it.

Learn more Examples

Fast Math Library

When doing anything with rendering, you unfortunately can't avoid maths.

But don't worry, we've got you covered!

PHP-GLFW includes a simple and fast math library, written in C, to minimize runtime overhead as much as possible. There will still be a significant overhead, though...

Many Utilities

Example of loading .obj files per drag and drop into a 3D scene.

PHP has never been made with GameDev or real-time applications in mind. Thus, there are many basic things missing you usally need when developing such applications.

PHP-GLFW tries to bridge this gap by providing various utilities:

  • Buffer Objects

    PHP arrays essentially are hashmaps, which are great but not so great for storing millions of floats. PHP-GLFW offers buffer objects for numeric data types, stored in a contiguous memory block, yet these can still be accessed like a PHP array.

  • File Loaders

    We include loaders for images (.png, .jpg, .gif, .bmp, .tga ) and 3D models ( .obj, .mtl).