You need to make sure you have the Apple Developer Tools, BSD Subsystem, and an installation of X before you try installing PHP-GTK 2. Although the BSD subsystem is installed by default on Mac OS X, you need select the Developer Tools and X Server manually. Although you can use any X server, the easiest would be to use the one Apple provides by default on it's Mac OS X installer.
Get MacPorts (previously knows as DarwinPorts) or Fink and install it. You can use either to install a version of X (if you decided not to use Apple's default distribution), and Gtk+ itself. Both Fink and MacPorts provide versions 2.6 and above of Gtk+. Also make sure you have a version of PHP that is atleast 5.2, MacPorts provides a package. Type php -v on your Terminal to find out your version. If you want to manually compile PHP you can do so: Although you may install it anywhere, /usr/local/ is usually considered a good place. MacPorts installs PHP into /opt/local/.
Now get the latest checkout of PHP-GTK and compile it: Remember to replace /usr/local/ with the actual directory in which you installed PHP. For example, if you installed PHP 5.2 using MacPorts, you would enter /opt/local/ instead.
Finally, copy over the php.ini-recommended file to /usr/local/lib/php.ini and change the value of extension_dir to the directory where php_gtk2.so resides. This is usually something like: /usr/local/lib/php/extensions/no-debug-non-zts-some-date. You may want to create a new symbolic link in /usr/bin/ that points to /usr/local/bin/php. Again, the directory may be /opt/local/ instead of /usr/local/ depending on where your installation of PHP resides.
Now continue with Testing your installation.
I installed php 7.2, even though it's not the latest, simply because my hosting site and wordpress uses php 7.2 and I want to integrate my php application with my wordpress site. $ brew install php@7.2 Once php is installed, go back to your httpd.conf file and add the following line.