Thursday, August 22, 2019

Using PHP and PerlBrew

I have phpbrew installed on my mac. I use it to manage my php installation.

The first command I used was

phpbrew known

to view the known PHP versions.

I had not installed any versions, so

phpbrew list

did not show me any.

So, I checked the version - 1.23. GitHub showed a newer version of 1.26. I decided to reinstall phpbrew.

https://github.com/phpbrew/phpbrew

  • used curl to install phpbrew.phar
  • moved to my path
  • made it executable
phpbrew system revealed that my PHP on my Mac under Mojave is outdated, so I installed 7.3 as my system PHP.

After installing, I updated my PATH with 

export PATH=/usr/local/php5/bin:$PATH

I will also add that to my .bashrc

I was trying to install a different PHP version and received errors about missing bzip2 and some other things. I wound up reinstalling Homebrew, because it could not update itself.

Homebrew prefix "/usr/local/Cellar/libxml2/2.9.3" does not exist.

Error: No available formula with the name "bzip2"

Homebrew formula "bzip2" not found.

Homebrew prefix "/usr/local/Cellar/oniguruma/5.9.6" does not exist.

Homebrew prefix "/usr/local/Cellar/mhash/0.9.9.9" does not exist.

Homebrew prefix "/usr/local/Cellar/curl/7.46.0" does not exist.

checking for ZLIB support... no

checking whether to enable bc style precision math functions... yes

checking for BZip2 support... yes

checking for BZip2 in default path... not found

configure: error: Please reinstall the BZip2 distribution

I tried to install some libraries

brew install zlib bzip2 libiconv curl

This is when I tried to update brew and had to reinstall. After brew install, I was able to install the above.

Next, I intalled

phpbrew install 7.4.5 +mysql +default

I still get the error

Homebrew prefix "/usr/local/Cellar/libxml2/2.9.10_1" does not exist.
Homebrew prefix "/usr/local/Cellar/oniguruma/6.9.5" does not exist.
Homebrew prefix "/usr/local/Cellar/mhash/0.9.9.9" does not exist.
Homebrew prefix "/usr/local/Cellar/openssl@1.1/1.1.1g" does not exist.

It looks like I need more stuff for Mac OS:

brew install autoconfig pkg-config

Then

brew upgrade

Could not find autoconfig formula.

Still can't install PHP. It did find the openssl folder.

brew install libxml2 onigurma mhash

Installed missing packages with brew.

Still can't install PHP versions.

Inspect

tail /Users/timdowney/.phpbrew/build/php-7.4.5/build.log

Missing link to pkg-config, tried

brew link pkg-config

Missing libzip

brew install libzip

Tried to install 7.4.5 again.

Congratulations! Now you have PHP with 7.4.5 as php-7.4.5

* We found that you enabled 'mysql' variant, you might need to setup your
  'pdo_mysql.default_socket' or 'mysqli.default_socket' in your php.ini file.

* To configure your installed PHP further, you can edit the config file at
    /Users/timdowney/.phpbrew/php/php-7.4.5/etc/php.ini

To use the newly built PHP, try the line(s) below:

    $ phpbrew use php-7.4.5

Or you can use switch command to switch your default php to php-7.4.5:

    $ phpbrew switch php-7.4.5












Followers