Setting up PHP locally
Ran into some hiccups following the productive instructions from Nikita Popov who appears to be using Linux (or some other similar Unix derivative). This is for macOS.
$ sudo apt-get install re2c
Did not work. I needed to install Homebrew first, which is an equivalent package manager to
apt-get for macOS; mileage may vary.
After successful installation I was able to run:
% brew install re2c % brew install bison
I continued with Nikita’s instructions until I hit the next hiccup -
autoconf not found.
I ran the following:
% brew install autoconf
And continued with Nikita’s instructions at:
% ./buildconf ...
I received two errors:
configure: error: bison 3.0.0 or later is required to generate PHP parsers (excluded versions: none). // And when running make -j4 make: *** No targets specified and no makefile found. Stop.
The second error is because of the first:
% bison --version // -v did not seem to work for me. // macOS installed version bison (GNU Bison) 2.3 % which bison // /usr/bin/bison
The Bison installer includes the following message:
bison is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble. If you need to have bison first in your PATH run: echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.zshrc For compilers to find bison you may need to set: export LDFLAGS="-L/usr/local/opt/bison/lib"
After trying to the configuration and whatnot again, still running into the same problem. The first command will put the echoed string into a hidden file called
.zshrc, which I didn’t find to work on macOS. I tried
.bash_profile instead. (I used Finder, but this should work as well, though I’m not sure if it will append or overwrite the contents; so, buyer beware.)
% echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile % bison --version // bison (GNU Bison) 3.6.4 % which bison // /usr/local/opt/bison/bin/bison
Seems like what we want. Trying configuration again:
% ./buildconf // received no errors % ./configure --disable-all --enable-debug --enable-maintainer-zts // received no errors
So, according to Nikita’s instructions, we should be able to do:
% sapi/cli/php -v // Error: zsh: no such file or directory: sapi/cli/php
Well, that’s my 30 minutes for today working toward being able to development in PHP Internals. Let’s see what happens tomorrow.