Skip to content

Installing PHP-GLFW on Windows

PHP-GLFW will not run properly under WSL (Windows Subsystem) so make sure you install PHP natively on windows. If you haven't already done so, check out the Installing PHP natively on Windows section.

Download DLL

For Windows, we provide a prebuilt DLL which you can simply download and place into your PHP extension folder.

  1. See the releases page for the latest DLL downloads: PHP-GLFW Releases
  2. Download the matching DLL for your local PHP installation. (If you are following this guide ts_x64)
  3. Move and rename the downloaded dll to your PHP's ext folder. Usually C:\php\ext\php_glfw.dll.
  4. Enable the extension in your php.ini (usually at C:\php\php.ini)
    extension=glfw
    

That's it, You can check if the extension is loaded properly with php -m.


Installing PHP natively on Windows

PHP-GLFW will not run properly under WSL (Windows Subsystem) so make sure you install PHP natively on windows. If you have already done so you can skip the next section.

  1. Go to https://windows.php.net/download#php-8.1 and download a x64 thread safe version of PHP.
  2. Extract the zip file and move the contents to C:\php. (You have to create that directory)
  3. Ensure this path is valid now, and points to an executable: C:\php\php.exe.
  4. Add C:\php to the Path environment variable.
    1. Press on windows start and search for environment.
    2. "Edit the system environment variables" should popup, open it.
    3. In the dialog, click on the tab "Advanced" and then on the button "Environment Variables..."
    4. In the "System Variables" list scroll down and edit the Path variable.
    5. In the edit dialog, click on the "New" and enter C:\php.
  5. Open up a NEW powershell or CMD and type php -v to verify the installation.

Build from Source

In order to build PHP-GLFW we need to the "Development Package".

  1. Clone the php-sdk: git clone https://github.com/php/php-sdk-binary-tools.git php-sdk, to drive root (C:\)
  2. cd C:\php-sdk
  3. Run the setup bat file, in my case I use the same architecture and SDK version as the downloaded precompiled PHP for windows. (phpsdk-vs16-x64.bat)
  4. phpsdk_buildtree phpmaster
  5. git clone https://github.com/php/php-src.git && cd php-src
  6. phpsdk_deps --update --branch 8.1
  7. Copy PHP-GLFW source into ext/glfw of the cloned PHP source code.
  8. run: buildconf && configure --disable-all --enable-cli --enable-glfw=shared && nmake
  9. the resulting dll should be located depending on your choosen build under x64\Release_TS\php_glfw.dll.