-
Install on Linux
-
Install on MacOS
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.
- See the releases page for the latest
DLLdownloads: PHP-GLFW Releases - Download the zip that matches your local PHP installation. The file names look like this:
Run
php_glfw-<release>-8.5-ts-vs17-x64.zip │ │ │ └ architecture │ │ └ Visual Studio version PHP was built with │ └ thread safety: "ts" or "nts" └ PHP versionphp -vto find the values for your PHP. It tells you the version,ZTS(thread safe, pickts) orNTS(picknts), and the Visual C++ version. If you are following this guide, you want thetsbuild for your PHP version. - Extract
php_glfw.dllfrom the zip into your PHP'sextfolder. Usually that'sC:\php\ext\php_glfw.dll. - Enable the extension in your
php.ini(usually atC:\php\php.ini)
That's it, You can check if the extension is loaded properly with php -m.
Seeing \"Can't load module ... as it's linked with 14.xx, but the core is linked with 14.yy\"?
This means the DLL was built for a different PHP than the one you are running. Double check that the PHP version and the ts/nts part of the zip name match the output of php -v. If you are on an older PHP-GLFW release, grab the latest one: releases before 2.4.1 shipped PHP 8.4 and 8.5 builds that were linked with a too new compiler.
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.
- Go to https://windows.php.net/download#php-8.1 and download a x64 thread safe version of PHP.
- Extract the zip file and move the contents to
C:\php. (You have to create that directory) - Ensure this path is valid now, and points to an executable:
C:\php\php.exe. - Add
C:\phpto thePathenvironment variable.- Press on windows start and search for environment.
- "Edit the system environment variables" should popup, open it.
- In the dialog, click on the tab "Advanced" and then on the button "Environment Variables..."
- In the "System Variables" list scroll down and edit the
Pathvariable. - In the edit dialog, click on the "New" and enter
C:\php.
- Open up a NEW powershell or CMD and type
php -vto verify the installation.
Build from Source¶
In order to build PHP-GLFW we need to the "Development Package".
- Clone the php-sdk:
git clone https://github.com/php/php-sdk-binary-tools.git php-sdk, to drive root (C:\) cd C:\php-sdk- 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) phpsdk_buildtree phpmastergit clone https://github.com/php/php-src.git && cd php-srcphpsdk_deps --update --branch 8.1- Copy PHP-GLFW source into
ext/glfwof the cloned PHP source code. - run:
buildconf && configure --disable-all --enable-cli --enable-glfw=shared && nmake - the resulting
dllshould be located depending on your choosen build underx64\Release_TS\php_glfw.dll.