Skip to content

Build on Windows

syracine69 edited this page Jan 28, 2023 · 29 revisions

This page provides step by step instructions on how to build PHP Desktop Chrome from sources.

Table of Contents

Requirements

These instructions are for building "chrome99" branch.

Requirements:

Download PHP Desktop sources

Clone git repository

Download CEF sources / prebuilt binaries

If you would like to use CEF prebuilt binaries then go to Spotify Automated CEF Builds. You have to download CEF for the same branch and revision that phpdesktop uses, see "cef/README.txt". Look for CEF version in that file. Choose "Standard Distribution" binaries.

If you would like to build CEF from sources then see CEF Branches and building (external) wiki page.

Build cefclient and copy CEF files to phpdesktop

The CEF binaries downloaded from Spotify after extracting have the "cef_binary_99.2.9+gf426765+chromium-99.0.4844.51_windows32" directory. From now on we will refer to this directory as "cef_binary/" directory.

  1. Install CMake 3.19.8 or newer from http://www.cmake.org/ . During installation choose an option to add cmake to user's PATH.
  2. Download Ninja from https://github.com/ninja-build/ninja/releases . Put ninja.exe in your PATH or copy it to the build/ directory you will be creating in next step.
  3. In "cef_binary/" create a "build" directory and enter it
  4. Create CC and CXX environment variables that contain path of cl.exe compiler. The binary should be located in path C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x86\cl.exe for Windows 10 64 bits.
  5. Add the previous directory in front of PATH environment variable. So, move up directory C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x86 and add it to System environment variables
  6. Execute "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat" (with quotes) - this sets environment variables for VS2019 for current session - all further commands need to be executed in current command window
  7. Execute cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DUSE_SANDBOX=OFF ..
  8. Execute ninja cefclient
  9. Go to the "cef_binary/build/tests/cefclient/Release/" directory and run cefclient.exe to see if it works fine
  10. Create "Release" directory inside "src" directory and copy files and subdirectories from the "cef_binary/Release/" and "cef_binary/Resources/" directories. Exclude any files with extension ".lib". You may also copy cefclient.exe and cefclient.pdb (if you have compiled cefclient as Debug) from the "cef_binary/build/cefclient/" directory.
  11. Copy "cef_binary/build/libcef_dll_wrapper/libcef_dll_wrapper.lib" and "cef_binary/Release/libcef.lib" to the "src/lib/Release/" directory.
  12. To clean the cef_binary build directory just delete it. To only clean ninja build and keep cmake files intact type ninja -t clean cefclient. If you need DEBUG binaries re-run commands starting from step 6 with DCMAKE_BUILD_TYPE=Debug and replace any "Release" directories mentioned with a "Debug" directory.

If you're building with version of CEF different from README.txt (eg. upgrading to a newer CEF) then delete the "src/cef/include/" directory and copy the "cef_binary/include/" directory (ignore the "capi" subdirectory). Also overwrite "src/cef/README.txt" file with "cef_binary/README.txt".

Download PHP binaries

Go to http://windows.php.net/download/ and download PHP for "x86" and "Non Thread Safe". Extract it and put binaries in "src/php/" directory.

IMPORTANT: Up to know, don't download PHP 8.x binaries. Because it doesn't comply with php-desktop architecture who now is x86 (32-bits).

Build phpdesktop-chrome project

  1. Go to "src/" directory
  2. Open phpdesktop-chrome.sln file in Visual Studio
  3. Change configuration to Release
  4. Build phpdesktop-chrome project. This will generate src/Release/phpdesktop-chrome.exe executable.
  5. Run phpdesktop-chrome.exe executable