-
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
DLL
downloads: PHP-GLFW Releases - Download the matching
DLL
for your local PHP installation. (If you are following this guidets_x64
) - Move and rename the downloaded
dll
to your PHP'sext
folder. UsuallyC:\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
.
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:\php
to thePath
environment 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
Path
variable. - In the edit dialog, click on the "New" and enter
C:\php
.
- 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".
- 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 phpmaster
git clone https://github.com/php/php-src.git && cd php-src
phpsdk_deps --update --branch 8.1
- Copy PHP-GLFW source into
ext/glfw
of the cloned PHP source code. - run:
buildconf && configure --disable-all --enable-cli --enable-glfw=shared && nmake
- the resulting
dll
should be located depending on your choosen build underx64\Release_TS\php_glfw.dll
.