{"id":13823868,"url":"https://github.com/mario-deluna/php-glfw","last_synced_at":"2025-05-15T20:05:41.968Z","repository":{"id":41423668,"uuid":"118034052","full_name":"mario-deluna/php-glfw","owner":"mario-deluna","description":"🪐A fully-featured OpenGL and GLFW extension for PHP. 🔋Batteries included (Math Functions, Texture Loaders, etc..)","archived":false,"fork":false,"pushed_at":"2025-05-10T17:27:17.000Z","size":50830,"stargazers_count":446,"open_issues_count":5,"forks_count":15,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-10T18:26:36.378Z","etag":null,"topics":["2d","3d","game","game-development","glfw","opengl","php","php-extension","rendering"],"latest_commit_sha":null,"homepage":"http://phpgl.net/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mario-deluna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-01-18T20:24:53.000Z","updated_at":"2025-05-04T18:30:23.000Z","dependencies_parsed_at":"2024-02-23T16:26:07.249Z","dependency_job_id":"0982f177-cbdd-43ef-8963-3b2a60a4f609","html_url":"https://github.com/mario-deluna/php-glfw","commit_stats":{"total_commits":540,"total_committers":2,"mean_commits":270.0,"dds":0.062962962962963,"last_synced_commit":"fe9bdc0a6c1d82c528fc801adf6062ce1a81ec12"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mario-deluna%2Fphp-glfw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mario-deluna%2Fphp-glfw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mario-deluna%2Fphp-glfw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mario-deluna%2Fphp-glfw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mario-deluna","download_url":"https://codeload.github.com/mario-deluna/php-glfw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254414499,"owners_count":22067272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d","3d","game","game-development","glfw","opengl","php","php-extension","rendering"],"created_at":"2024-08-04T09:00:47.527Z","updated_at":"2025-05-15T20:05:36.890Z","avatar_url":"https://github.com/mario-deluna.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n \u003cimg width=\"500px\" src=\"https://raw.githubusercontent.com/phpgl/docs-assets/master/php-glfw/logos/logo_with_text.svg\"\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003e PHP-GLFW\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/mario-deluna/php-glfw/blob/master/LICENSE\" title=\"license\"\u003e\u003cimg alt=\"LICENSE\" src=\"https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative\u0026logoColor=white\u0026labelColor=555555\"\u003e\u003c/a\u003e\n  \u003ca href=\"#tada-php-support\" title=\"PHP Versions Supported\"\u003e\u003cimg alt=\"PHP Versions Supported\" src=\"https://img.shields.io/badge/php-8.0%20to%208.3-777bb3.svg?logo=php\u0026logoColor=white\u0026labelColor=555555\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/mario-deluna/php-glfw/releases/\"\u003e\u003cimg src=\"https://img.shields.io/github/tag/mario-deluna/php-glfw?include_prereleases=\u0026sort=semver\u0026color=blue\" alt=\"GitHub tag\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/mario-deluna/php-glfw/issues\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/mario-deluna/php-glfw\" alt=\"issues - php-glfw\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/mario-deluna/php-glfw/actions/workflows/build.yml\" title=\"PHP-GLFW Tests\"\u003e\u003cimg alt=\"PHP-GLFW Tests\" \n  src=\"https://github.com/mario-deluna/php-glfw/actions/workflows/build.yml/badge.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/mario-deluna/php-glfw/actions/workflows/macos_installer.yml\" title=\"MacOS Installer\"\u003e\u003cimg alt=\"MacOS Installer\"\n  src=\"https://github.com/mario-deluna/php-glfw/actions/workflows/macos_installer.yml/badge.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/mario-deluna/php-glfw/actions/workflows/windows.yml\" title=\"Windows Build\"\u003e\u003cimg alt=\"Windows Build\"\n  src=\"https://github.com/mario-deluna/php-glfw/actions/workflows/windows.yml/badge.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\n**[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)**\n\n**A fully-featured OpenGL and GLFW extension for PHP. Batteries included 🔋!**\n\n\u003c!-- [![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)\n[![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)\n[![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) --\u003e\n\nPHP-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.\n\n\u003cp align=\"center\"\u003e\n \u003cimg width=\"720px\" src=\"https://user-images.githubusercontent.com/956212/196137371-74546845-4101-4e22-8d1c-4550f0ba2adf.gif\" alt=\"3D Rendering in PHP\"\u003e\n\u003c/p\u003e\n\n_Currently supports **PHP8.x**_\n\n- [What is this extension? Discover the features 🚀](#what-is-this-extension-features-)\n  + [OpenGL](#opengl)\n  + [GLFW](#glfw)\n  + [Vector Graphics API](#vector-graphics-api)\n  + [PHPGL - Math](#phpgl---math)\n  + [PHPGL - Buffers](#phpgl---buffers)\n  + [PHPGL - Textures](#phpgl---textures)\n  + [PHPGL - Geometry](#phpgl---geometry)\n  + [How are the bindings achieved?](#how-are-the-bindings-achieved)\n- [Documentation 📚](#documentation-)\n- [Examples](#examples)\n  + [Game - FlappyPHPant](#flappyphpant)\n  + [Emulator - PHP-CHIP8](#php-chip8)\n  + [Game - PHP Towerdefense](#php-towerdense-game)\n- [Installation](#installation)\n  + [MacOS](#macos)\n  + [Linux](#linux)\n  + [Stubs (IDE Support)](#stubs-ide-support)\n- [Credits](#credits)\n- [License](#license)\n\n## What is this extension? Features 🚀\n\nPHP-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.\n\n### OpenGL\n\n* Full native support for **OpenGL** (4.1+ core), bringing GPU-accelerated rendering to PHP.\n* Targets OpenGL 4.1, but can be built for newer versions as well.\n* Support for OpenGL extensions (limited).\n* Mirrors the C API as closely as possible, with adjustments made where required or otherwise nonsensical.\n* Supports ~90% of the full standard; see [GLSUPPORT.md](./GLSUPPORT.md) for details.\n\n### GLFW\n\nThis extension includes bindings for the powerful **[GLFW](https://www.glfw.org)** library, offering a range of amazing features, such as:\n\n* Multiplatform Window creation and handling (MacOS / Windows / Linux)\n* Support for multiple windows and monitors\n* Real-time user input handling\n  * **Keyboard and Mouse** event handling\n  * **Joystick** input support\n  * **Gamepad** Support\n\n### Vector Graphics API\n\nPHP-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.\n\n\u003cp align=\"left\"\u003e\n \u003cimg alt=\"PHP Vector Graphics Rendering Library\" src=\"https://github.com/user-attachments/assets/be534c0e-f0c3-4201-bd98-d7725e3b62ed\" align=\"center\" width=\"600\" \u003e\n\u003c/p\u003e\n\n- Allows for quick and intuitive rendering of primitives.\n- Includes numerous helpers for colors.\n- Supports gradients and images.\n- Easily renders text with any font.\n- Ideal for quickly creating GUIs.\n\n1. [Read more about the Vector Graphics API](https://phpgl.net/user-guide/vector-graphics/creating_a_vgcontext.html)\n\n### PHPGL - Math\n\nPHP-GLFW comes with a built-in mathematics library, written in C and optimized for graphical applications.\n\n\u003cp align=\"left\"\u003e\n \u003cimg alt=\"PHP Vector Math Library\" src=\"https://github.com/user-attachments/assets/99b19edc-6679-46c7-82a9-7b0969fce96a\" align=\"center\" width=\"600\" \u003e\n\u003c/p\u003e\n\n* Supported structs: `Vec2`, `Vec3`, `Vec4`, `Mat4`, and `Quat`\n* Includes most common matrix operations, like: `lookAt`, `perspective`, `inverse`, `rotate`, and more\n\nIntegration into the extension offers several advantages:\n\n* High performance\n* Low memory footprint\n* Overloaded operators for math structs, enabling intuitive operations like:\n  ```php\n  use GL\\Math\\Vec2;\n  $v3 = Vec2(15, -5) + Vec2(42, 7); // returns Vec2(57, 2)\n  ```\n* Some OpenGL functions directly accept math structs as arguments\n\n1. [Read more about math functions](https://phpgl.net/user-guide/math/math_functions.html)\n\n### PHPGL - Buffers\n\nThis extension also includes a set of buffer objects that internally hold data in native types.\n\n* Can handle large arrays of data\n* Low memory footprint and very fast\n* Data is stored internally to be directly uploadable to the GPU\n\n1. [Read more about the buffers](https://phpgl.net/API/Buffer/FloatBuffer.html)\n\n### PHPGL - Textures\n\nPHP-GLFW supports the loading of images/textures into buffers without requiring an additional extension:\n\n* Can load common image formats, like `jpg`, `png`, `tga`, `bmp`, and `gif` _(gd or Imagick is not required)_\n* Can write images/textures back to disk\n* Writes data into a `BufferInterface` object, providing full access to the bitmap\n\n1. [Read more about texture loading](https://phpgl.net/API/Texture/Texture2D.html)\n\n### PHPGL - Geometry\n\nPHP-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.\n\n* Can parse `.obj` and `.mtl` files\n* Can generate normal, tangent, and bitangent vectors for the loaded geometry on the fly\n* Allows extraction of separate meshes and groups from the loaded geometry\n* Can group vertices by their material\n* Can reindex extracted meshes to reduce the number of vertices\n\n1. [Read more about geometry loading](https://phpgl.net/API/Geometry/ObjFileParser.html)\n\n### How are the bindings achieved?\n\nPHP-GLFW parses the OpenGL specs to generate most of the C extension, instead of porting functions manually. Manual adjustments are made where necessary.\n\n## Documentation 📚\n\n\u003e 1. [Full Documentation](https://phpgl.net)\n\u003e 2. [Getting Started Guide](https://phpgl.net/getting-started/window-creation.html)\n\u003e 3. [User Guide](https://phpgl.net/user-guide/vector-graphics/creating_a_vgcontext.html)\n\u003e 4. [API Docs](https://phpgl.net/API/Buffer/ByteBuffer.html)\n\n## Examples\n\n[![glfw-previews](https://user-images.githubusercontent.com/956212/189208007-74064a7b-0e93-4d7f-b53e-e799a0641e54.png)](./examples#examples)\n\nExplore the [examples](./examples#examples) directory to dive into the code.\n\n### FlappyPHPant\n\nA very simple Flappy Bird-like game written in PHP.\n\n\u003cp align=\"center\"\u003e\n   \u003cimg width=\"640\" src=\"https://github.com/phpgl/flappyphpant/assets/956212/9d32a533-73cb-40e6-b940-7976b765d658\" alt=\"FlappyPHPant 2D PHP Game\"\u003e\n\u003c/p\u003e\n\nhttps://github.com/phpgl/flappyphpant\n\n\n### php-chip8\n\nYet another CHIP-8 emulator, but in PHP!\n\n\u003cp align=\"center\"\u003e\n   \u003cimg width=\"640\" src=\"https://github.com/mario-deluna/php-chip8/assets/956212/ae03baa0-8a00-4872-8131-39ca420a6310\" alt=\"A CHIP-8 Game Emulator written in PHP\"\u003e\n\u003c/p\u003e\n\nhttps://github.com/mario-deluna/php-chip8\n\n\n### PHP-Towerdense Game\n\nWe 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.\n\n\u003cp align=\"center\"\u003e\n \u003cimg width=\"80%\" alt=\"PHP-TowerDefense Screenshot\" src=\"https://user-images.githubusercontent.com/956212/222989984-e1b2d431-26de-47f4-a17d-7800e5afb052.jpg\"\u003e\n\u003c/p\u003e\nCheck out the game's repository on GitHub for more information and to follow its progress: https://github.com/phpgl/php-towerdefense\n\n### php-pong\n\nClassic Pong game programmed with pure OpenGL wrapped in OOP code.\n\n\u003cp align=\"center\"\u003e\n   \u003cimg width=\"640\" src=\"https://raw.githubusercontent.com/medilies/php-pong/main/screened.gif\" alt=\"Classic Pong Game written in PHP\"\u003e\n\u003c/p\u003e\n\nhttps://github.com/medilies/php-pong\n\n## Installation \n\n**Please refer to the comprehensive installation guide here: [Installation](https://phpgl.net/getting-started/installation/install-linux.html)**\n\n\u003e **PHP Version:** `\u003e= 8.0`\n\u003e While I would love to support older PHP builds, it was just not feasible for this extension.\n\n### MacOS \n\n#### Installer\n\nYou can use a simple installer script to install PHP-GLFW:\n\n```\nphp -r \"copy('https://raw.githubusercontent.com/mario-deluna/php-glfw/master/install/macos-installer.php', 'phpglfw-installer.php');\" \u0026\u0026 php phpglfw-installer.php\n```\n\nOnce you see \"Installation finished!\", you're ready to go!\n\n#### Manual installation\n\nFor a manual approach, ensure you have installed the `php-dev`, `git`, and `cmake` packages. **They are required!**\n\n```bash\ngit clone https://github.com/mario-deluna/php-glfw\ncd php-glfw\nsudo phpize \u0026\u0026 ./configure --enable-glfw\nsudo make install\n```\n\nDon't forget to add `glfw.so` in the `php.ini` file:\n\n```ini\nextension=\"glfw.so\"\n```\n\n### Linux \n\n`cmake` is required for the installation. You can skip the first step if it's already installed.\nAlso, make sure that you install the `php-dev` package, for example, `php8.1-dev`.\n\n```\nsudo apt install -y cmake git \ngit clone https://github.com/mario-deluna/php-glfw\ncd php-glfw\nsudo phpize \u0026\u0026 ./configure --enable-glfw\nsudo make install\n```\n\nMake sure to add `glfw.so` in the `php.ini` file:\n\n```ini\nextension=\"glfw.so\"\n```\n\n### Stubs (IDE Support)\n\nAs this is a PHP extension, your editor / IDE does not support auto-completion and doc lookups without some help.\nWe created a composer package you can include as a dev dependency to have full support:\n\n```\ncomposer require --dev phpgl/ide-stubs\n```\n\n## Credits\n\n- [Mario Döring](https://github.com/mario-deluna)\n- [All Contributors](https://github.com/mario-deluna/php-glfw/contributors)\n\n## License\n\nPlease see [License File](https://github.com/mario-deluna/php-glfw/blob/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmario-deluna%2Fphp-glfw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmario-deluna%2Fphp-glfw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmario-deluna%2Fphp-glfw/lists"}