PHPackages                             mario-deluna/php-glfw - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mario-deluna/php-glfw

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

mario-deluna/php-glfw
=====================

A fully-featured OpenGL and GLFW extension for PHP.

v2.3.0(7mo ago)56257—0%19[3 PRs](https://github.com/mario-deluna/php-glfw/pulls)MITCPHP &gt;= 8.0.0CI passing

Since Dec 26Pushed 2mo ago12 watchersCompare

[ Source](https://github.com/mario-deluna/php-glfw)[ Packagist](https://packagist.org/packages/mario-deluna/php-glfw)[ GitHub Sponsors](https://github.com/mario-deluna)[ RSS](/packages/mario-deluna-php-glfw/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (1)Versions (11)Used By (0)

 [![](https://raw.githubusercontent.com/phpgl/docs-assets/master/php-glfw/logos/logo_with_text.svg)](https://raw.githubusercontent.com/phpgl/docs-assets/master/php-glfw/logos/logo_with_text.svg)

 PHP-GLFW
=========

[](#-php-glfw)

 [![LICENSE](https://camo.githubusercontent.com/b7f987d9672849c198f174fdcafb8cc6d9878e439d03e9403c34683de445b87e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d3432386637652e7376673f6c6f676f3d6f70656e253230736f75726365253230696e6974696174697665266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d353535353535)](https://github.com/mario-deluna/php-glfw/blob/master/LICENSE "license") [![PHP Versions Supported](https://camo.githubusercontent.com/161ddacff2edada642ad62907f9f378b58a97b563a7d55d01bb661699f0539f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e30253230746f253230382e342d3737376262332e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d353535353535)](#tada-php-support "PHP Versions Supported") [![GitHub tag](https://camo.githubusercontent.com/d9e0762a6777a08228e28943d8da9367d1f7fb56bc154722e2cd7513d50a38f0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f6d6172696f2d64656c756e612f7068702d676c66773f696e636c7564655f70726572656c65617365733d26736f72743d73656d76657226636f6c6f723d626c7565)](https://github.com/mario-deluna/php-glfw/releases/) [![issues - php-glfw](https://camo.githubusercontent.com/7eb423b018d64ff484a63e231051d415cf058b8359a33f1380bdfe1723153242/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6d6172696f2d64656c756e612f7068702d676c6677)](https://github.com/mario-deluna/php-glfw/issues)

 [![PHP-GLFW Tests](https://github.com/mario-deluna/php-glfw/actions/workflows/build.yml/badge.svg)](https://github.com/mario-deluna/php-glfw/actions/workflows/build.yml "PHP-GLFW Tests") [![MacOS Installer](https://github.com/mario-deluna/php-glfw/actions/workflows/macos_installer.yml/badge.svg)](https://github.com/mario-deluna/php-glfw/actions/workflows/macos_installer.yml "MacOS Installer") [![Windows Build](https://github.com/mario-deluna/php-glfw/actions/workflows/windows.yml/badge.svg)](https://github.com/mario-deluna/php-glfw/actions/workflows/windows.yml "Windows Build")

**[Website](https://phpgl.net) • [Getting Started](https://phpgl.net/getting-started/getting-started-with-php-and-opengl.html) • [API Docs](https://phpgl.net/API/Buffer/ByteBuffer.html) • [Examples](https://phpgl.net/examples/00-about-examples.html)**

**A fully-featured OpenGL and GLFW extension for PHP. Batteries included 🔋!**

PHP-GLFW allows you to create *2D* and *3D* real-time applications in *PHP*. It introduces a whole new set of tools for PHP developers to build graphical applications like *games, scientific simulations, user interfaces*, and much more.

 [![3D Rendering in PHP](https://user-images.githubusercontent.com/956212/196137371-74546845-4101-4e22-8d1c-4550f0ba2adf.gif)](https://user-images.githubusercontent.com/956212/196137371-74546845-4101-4e22-8d1c-4550f0ba2adf.gif)

*Currently supports **PHP8.x***

- [What is this extension? Discover the features 🚀](#what-is-this-extension-features-)
    - [OpenGL](#opengl)
    - [GLFW](#glfw)
    - [Vector Graphics API](#vector-graphics-api)
    - [PHPGL - Math](#phpgl---math)
    - [PHPGL - Buffers](#phpgl---buffers)
    - [PHPGL - Textures](#phpgl---textures)
    - [PHPGL - Geometry](#phpgl---geometry)
    - [How are the bindings achieved?](#how-are-the-bindings-achieved)
- [Documentation 📚](#documentation-)
- [Examples](#examples)
    - [Game - FlappyPHPant](#flappyphpant)
    - [Emulator - PHP-CHIP8](#php-chip8)
    - [Game - PHP Towerdefense](#php-towerdense-game)
- [Installation](#installation)
    - [MacOS](#macos)
    - [Linux](#linux)
    - [Stubs (IDE Support)](#stubs-ide-support)
- [Credits](#credits)
- [License](#license)

What is this extension? Features 🚀
----------------------------------

[](#what-is-this-extension-features-)

PHP-GLFW aims to be a complete solution containing everything you need to start building graphical applications in PHP. It doesn't just provide **GLFW library bindings**, but also includes **OpenGL bindings** and a set of essential classes and helpers.

### OpenGL

[](#opengl)

- Full native support for **OpenGL** (4.1+ core), bringing GPU-accelerated rendering to PHP.
- Targets OpenGL 4.1, but can be built for newer versions as well.
- Support for OpenGL extensions (limited).
- Mirrors the C API as closely as possible, with adjustments made where required or otherwise nonsensical.
- Supports ~90% of the full standard; see [GLSUPPORT.md](./GLSUPPORT.md) for details.

### GLFW

[](#glfw)

This extension includes bindings for the powerful **[GLFW](https://www.glfw.org)** library, offering a range of amazing features, such as:

- Multiplatform Window creation and handling (MacOS / Windows / Linux)
- Support for multiple windows and monitors
- Real-time user input handling
    - **Keyboard and Mouse** event handling
    - **Joystick** input support
    - **Gamepad** Support

### Vector Graphics API

[](#vector-graphics-api)

PHP-GLFW includes a vector graphics API that allows you to draw in a HTML canvas-like manner in PHP. Its uses the same OpenGL context internally allowing you to build complex rendering pipelines utilizing both the vector graphics API and the more low-level OpenGL API.

 [![PHP Vector Graphics Rendering Library](https://private-user-images.githubusercontent.com/956212/369347340-be534c0e-f0c3-4201-bd98-d7725e3b62ed.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQxNzk2ODksIm5iZiI6MTc3NDE3OTM4OSwicGF0aCI6Ii85NTYyMTIvMzY5MzQ3MzQwLWJlNTM0YzBlLWYwYzMtNDIwMS1iZDk4LWQ3NzI1ZTNiNjJlZC5naWY_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzIyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMyMlQxMTM2MjlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01NTYxYWNiYTcyNzlmMGEyZWY0NTE0ZDE2YzQ4ZGY4MGM1N2QwYjQ4ZWE1NTI3NzRjYjhlODY4OGNlODE2NDE4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.OZ0sTrHGQwbMxdzdbcL5eO8jB6Udpal_nW8xhj6OK2E)](https://private-user-images.githubusercontent.com/956212/369347340-be534c0e-f0c3-4201-bd98-d7725e3b62ed.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQxNzk2ODksIm5iZiI6MTc3NDE3OTM4OSwicGF0aCI6Ii85NTYyMTIvMzY5MzQ3MzQwLWJlNTM0YzBlLWYwYzMtNDIwMS1iZDk4LWQ3NzI1ZTNiNjJlZC5naWY_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzIyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMyMlQxMTM2MjlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01NTYxYWNiYTcyNzlmMGEyZWY0NTE0ZDE2YzQ4ZGY4MGM1N2QwYjQ4ZWE1NTI3NzRjYjhlODY4OGNlODE2NDE4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.OZ0sTrHGQwbMxdzdbcL5eO8jB6Udpal_nW8xhj6OK2E)

- Allows for quick and intuitive rendering of primitives.
- Includes numerous helpers for colors.
- Supports gradients and images.
- Easily renders text with any font.
- Ideal for quickly creating GUIs.

1. [Read more about the Vector Graphics API](https://phpgl.net/user-guide/vector-graphics/creating_a_vgcontext.html)

### PHPGL - Math

[](#phpgl---math)

PHP-GLFW comes with a built-in mathematics library, written in C and optimized for graphical applications.

 [![PHP Vector Math Library](https://private-user-images.githubusercontent.com/956212/369344606-99b19edc-6679-46c7-82a9-7b0969fce96a.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQxNzk2ODksIm5iZiI6MTc3NDE3OTM4OSwicGF0aCI6Ii85NTYyMTIvMzY5MzQ0NjA2LTk5YjE5ZWRjLTY2NzktNDZjNy04MmE5LTdiMDk2OWZjZTk2YS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzIyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMyMlQxMTM2MjlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hOTQwZDdmNDY4YTkxOWIzMjc5ZjRmMDc4N2RlNWQ3ZDFmYjdmZGJlYWQ2NTE1MzFhZTUyYjg0OTQyNzVhZDQwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Tf7rlnVyjUgdvJdH9OZloR_kFphffitWo-W6gr8h2NQ)](https://private-user-images.githubusercontent.com/956212/369344606-99b19edc-6679-46c7-82a9-7b0969fce96a.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQxNzk2ODksIm5iZiI6MTc3NDE3OTM4OSwicGF0aCI6Ii85NTYyMTIvMzY5MzQ0NjA2LTk5YjE5ZWRjLTY2NzktNDZjNy04MmE5LTdiMDk2OWZjZTk2YS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzIyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMyMlQxMTM2MjlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hOTQwZDdmNDY4YTkxOWIzMjc5ZjRmMDc4N2RlNWQ3ZDFmYjdmZGJlYWQ2NTE1MzFhZTUyYjg0OTQyNzVhZDQwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Tf7rlnVyjUgdvJdH9OZloR_kFphffitWo-W6gr8h2NQ)

- Supported structs: `Vec2`, `Vec3`, `Vec4`, `Mat4`, and `Quat`
- Includes most common matrix operations, like: `lookAt`, `perspective`, `inverse`, `rotate`, and more

Integration into the extension offers several advantages:

- High performance
- Low memory footprint
- Overloaded operators for math structs, enabling intuitive operations like: ```
    use GL\Math\Vec2;
    $v3 = Vec2(15, -5) + Vec2(42, 7); // returns Vec2(57, 2)
    ```
- Some OpenGL functions directly accept math structs as arguments

1. [Read more about math functions](https://phpgl.net/user-guide/math/math_functions.html)

### PHPGL - Buffers

[](#phpgl---buffers)

This extension also includes a set of buffer objects that internally hold data in native types.

- Can handle large arrays of data
- Low memory footprint and very fast
- Data is stored internally to be directly uploadable to the GPU

1. [Read more about the buffers](https://phpgl.net/API/Buffer/FloatBuffer.html)

### PHPGL - Textures

[](#phpgl---textures)

PHP-GLFW supports the loading of images/textures into buffers without requiring an additional extension:

- Can load common image formats, like `jpg`, `png`, `tga`, `bmp`, and `gif` *(gd or Imagick is not required)*
- Can write images/textures back to disk
- Writes data into a `BufferInterface` object, providing full access to the bitmap

1. [Read more about texture loading](https://phpgl.net/API/Texture/Texture2D.html)

### PHPGL - Geometry

[](#phpgl---geometry)

PHP-GLFW comes with a `.obj` wavefront file loader, allowing you to load and parse `.obj` files. It also provides helpers to generate tangent and bitangent vectors for the loaded geometry. Currently, only triangulated geometry is supported, with no support for quads.

- Can parse `.obj` and `.mtl` files
- Can generate normal, tangent, and bitangent vectors for the loaded geometry on the fly
- Allows extraction of separate meshes and groups from the loaded geometry
- Can group vertices by their material
- Can reindex extracted meshes to reduce the number of vertices

1. [Read more about geometry loading](https://phpgl.net/API/Geometry/ObjFileParser.html)

### How are the bindings achieved?

[](#how-are-the-bindings-achieved)

PHP-GLFW parses the OpenGL specs to generate most of the C extension, instead of porting functions manually. Manual adjustments are made where necessary.

Documentation 📚
---------------

[](#documentation-)

> 1. [Full Documentation](https://phpgl.net)
> 2. [Getting Started Guide](https://phpgl.net/getting-started/window-creation.html)
> 3. [User Guide](https://phpgl.net/user-guide/vector-graphics/creating_a_vgcontext.html)
> 4. [API Docs](https://phpgl.net/API/Buffer/ByteBuffer.html)

Examples
--------

[](#examples)

[![glfw-previews](https://user-images.githubusercontent.com/956212/189208007-74064a7b-0e93-4d7f-b53e-e799a0641e54.png)](./examples#examples)

Explore the [examples](./examples#examples) directory to dive into the code.

### FlappyPHPant

[](#flappyphpant)

A very simple Flappy Bird-like game written in PHP.

 [![FlappyPHPant 2D PHP Game](https://private-user-images.githubusercontent.com/956212/258669173-9d32a533-73cb-40e6-b940-7976b765d658.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQxNzk2ODksIm5iZiI6MTc3NDE3OTM4OSwicGF0aCI6Ii85NTYyMTIvMjU4NjY5MTczLTlkMzJhNTMzLTczY2ItNDBlNi1iOTQwLTc5NzZiNzY1ZDY1OC5naWY_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzIyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMyMlQxMTM2MjlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mZjdmMzljYmUwNTU5YWY2NTU2NmNkZTlkNzk4NzI4M2QzZDIzNjEzMzdlNGYzNjY4NTAwYjkxMjU3ZDM5ODRkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.KG6XCGhDeNmA8oCz2dUCzCskDl545bbAqxy03NZIXAo)](https://private-user-images.githubusercontent.com/956212/258669173-9d32a533-73cb-40e6-b940-7976b765d658.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQxNzk2ODksIm5iZiI6MTc3NDE3OTM4OSwicGF0aCI6Ii85NTYyMTIvMjU4NjY5MTczLTlkMzJhNTMzLTczY2ItNDBlNi1iOTQwLTc5NzZiNzY1ZDY1OC5naWY_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzIyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMyMlQxMTM2MjlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mZjdmMzljYmUwNTU5YWY2NTU2NmNkZTlkNzk4NzI4M2QzZDIzNjEzMzdlNGYzNjY4NTAwYjkxMjU3ZDM5ODRkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.KG6XCGhDeNmA8oCz2dUCzCskDl545bbAqxy03NZIXAo)

### php-chip8

[](#php-chip8)

Yet another CHIP-8 emulator, but in PHP!

 [![A CHIP-8 Game Emulator written in PHP](https://private-user-images.githubusercontent.com/956212/309742225-ae03baa0-8a00-4872-8131-39ca420a6310.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQxNzk2ODksIm5iZiI6MTc3NDE3OTM4OSwicGF0aCI6Ii85NTYyMTIvMzA5NzQyMjI1LWFlMDNiYWEwLThhMDAtNDg3Mi04MTMxLTM5Y2E0MjBhNjMxMC5naWY_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzIyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMyMlQxMTM2MjlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03Njc0OTFmNzFmZTgxYTZiZWQxNjRmYTQ2MjdkZTg0NDg3OGM2YmRkOGI0ZjQ1MmFhNWY0YmFkNDJkOGY2MmU1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.3ra3UNMXHi5lNmOCin_UFNiJR5VRNC9mUWnU1IAyP8U)](https://private-user-images.githubusercontent.com/956212/309742225-ae03baa0-8a00-4872-8131-39ca420a6310.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQxNzk2ODksIm5iZiI6MTc3NDE3OTM4OSwicGF0aCI6Ii85NTYyMTIvMzA5NzQyMjI1LWFlMDNiYWEwLThhMDAtNDg3Mi04MTMxLTM5Y2E0MjBhNjMxMC5naWY_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzIyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMyMlQxMTM2MjlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03Njc0OTFmNzFmZTgxYTZiZWQxNjRmYTQ2MjdkZTg0NDg3OGM2YmRkOGI0ZjQ1MmFhNWY0YmFkNDJkOGY2MmU1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.3ra3UNMXHi5lNmOCin_UFNiJR5VRNC9mUWnU1IAyP8U)

### PHP-Towerdense Game

[](#php-towerdense-game)

We are currently developing a 3D game entirely built with PHP, leveraging the power of PHP-GLFW. The game, named PHP-TowerDefense, is open-source and serves as a showcase for the capabilities of PHP-GLFW. Although the game is in active development, it is not yet ready for release.

 [![PHP-TowerDefense Screenshot](https://user-images.githubusercontent.com/956212/222989984-e1b2d431-26de-47f4-a17d-7800e5afb052.jpg)](https://user-images.githubusercontent.com/956212/222989984-e1b2d431-26de-47f4-a17d-7800e5afb052.jpg)

Check out the game's repository on GitHub for more information and to follow its progress: ### php-pong

[](#php-pong)

Classic Pong game programmed with pure OpenGL wrapped in OOP code.

 [![Classic Pong Game written in PHP](https://raw.githubusercontent.com/medilies/php-pong/main/screened.gif)](https://raw.githubusercontent.com/medilies/php-pong/main/screened.gif)

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

[](#installation)

**Please refer to the comprehensive installation guide here: [Installation](https://phpgl.net/getting-started/installation/install-linux.html)**

> **PHP Version:** `>= 8.0`While I would love to support older PHP builds, it was just not feasible for this extension.

### MacOS

[](#macos)

#### Installer

[](#installer)

You can use a simple installer script to install PHP-GLFW:

```
php -r "copy('https://raw.githubusercontent.com/mario-deluna/php-glfw/master/install/macos-installer.php', 'phpglfw-installer.php');" && php phpglfw-installer.php

```

Once you see "Installation finished!", you're ready to go!

#### Manual installation

[](#manual-installation)

For a manual approach, ensure you have installed the `php-dev`, `git`, and `cmake` packages. **They are required!**

```
git clone https://github.com/mario-deluna/php-glfw
cd php-glfw
sudo phpize && ./configure --enable-glfw
sudo make install
```

Don't forget to add `glfw.so` in the `php.ini` file:

```
extension="glfw.so"
```

### Linux

[](#linux)

`cmake` is required for the installation. You can skip the first step if it's already installed. Also, make sure that you install the `php-dev` package, for example, `php8.1-dev`.

```
sudo apt install -y cmake git
git clone https://github.com/mario-deluna/php-glfw
cd php-glfw
sudo phpize && ./configure --enable-glfw
sudo make install

```

Make sure to add `glfw.so` in the `php.ini` file:

```
extension="glfw.so"
```

### Stubs (IDE Support)

[](#stubs-ide-support)

As this is a PHP extension, your editor / IDE does not support auto-completion and doc lookups without some help. We created a composer package you can include as a dev dependency to have full support:

```
composer require --dev phpgl/ide-stubs

```

Credits
-------

[](#credits)

- [Mario Döring](https://github.com/mario-deluna)
- [All Contributors](https://github.com/mario-deluna/php-glfw/contributors)

License
-------

[](#license)

Please see [License File](https://github.com/mario-deluna/php-glfw/blob/master/LICENSE) for more information.

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance83

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~203 days

Total

3

Last Release

222d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e61ab6a12a82ed3b52c6e12b8da02b5b903f4833b6e503ac94738c1a9e16c345?d=identicon)[mario-deluna](/maintainers/mario-deluna)

---

Top Contributors

[![mario-deluna](https://avatars.githubusercontent.com/u/956212?v=4)](https://github.com/mario-deluna "mario-deluna (642 commits)")

---

Tags

2d3dgamegame-developmentglfwopenglphpphp-extensionrendering

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mario-deluna-php-glfw/health.svg)

```
[![Health](https://phpackages.com/badges/mario-deluna-php-glfw/health.svg)](https://phpackages.com/packages/mario-deluna-php-glfw)
```

###  Alternatives

[stuttter/wp-user-profiles

A sophisticated way to edit users in WordPress

11219.3k1](/packages/stuttter-wp-user-profiles)[fof/analytics

Tracks analytics using Google Analytics, Google Optimize/GTM and Matomo

3543.1k](/packages/fof-analytics)[chrico/wp-fields

Package which provides some re-usable fields for WordPress.

1981.2k](/packages/chrico-wp-fields)[aertmann/history

An improved history backend module for Neos

1070.2k](/packages/aertmann-history)

PHPackages © 2026

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