Mac install ioncube with brew 7.2 - php

I've been looking around online and can't find the answer to my question.
I want to install ioncube on a mac with PHP#7.2 via home brew however nowhere seems to explain how to do it.
There are a lots of instances where it says to download it and then:
$ sudo cp ~/Downloads/ioncube/ioncube_loader_dar_7.2.so /usr/lib/php/extensions/no-debug-non-zts/20090626/
However, my issue is 1. permissions and 2. when brew changes location for the PHP install after an update I lose the ioncube.
Any insight would be appreciated.

Related

How do I install imagemagick to php on linux homebrew?

I'm trying to set up my linux environment to use PHP for my job. I'll spare you most of the details, but one extension I need is ImageMagick. I'm using Homebrew to help me install stuff. I'm using PHP 7.4. The commands I've run based on what I've read are as follows:
brew install php#7.4
brew install imagemagick
pecl install imagcik
However, when running the last command, I get this error, saying pcre2.h not found:
error image
I've done a lot of googling and haven't been able to find anything that helps with this specific issue. I don't know what I'm doing wrong. Everything is currently done through homebrew, but if it helps my linux distro is OpenSUSE Tumbleweed. Thanks!
Assuming that you did install pcre2 (if you didn't, run the command below and try again).
$ brew install pcre2
If that does not work, the issue is probably that the file exists, but in the wrong spot. A quick Google search shows that creating a symlink can resolve this issue.
$ ln -s <path to package> /home/linuxbrew/.linuxbrew/Cellar/php#7.4/7.4.27/include/php/ext/pcre/pcre2.h
If you're unsure where the package is currently installed. You should be able to find it with this command.
$ brew info pcre2

GNU MP Library version 4.2 or greater required

This is something i've met while trying to install PHP-GMP extension.
What i was trying to do is:
Downloaded gmp with brew using brew install autoconf gmp
Downloaded PHP (i'm using version 7.3.24) from source to extract the GMP extension
Copied Gmp directory to /Applications/MAMP/bin/php/php7.3.24/include/php/ext
Entered that dir and launched phpize
Launched `./configure --with-php-config=/Applications/MAMP/bin/php/php7.3.24/bin/php-config
As soon as i hit enter it starts doing it's stuff until it says:
configure: error: GNU MP Library version 4.2 or greater required.
Once i managed to solve this somehow but i really don't know how i did it. I can only remember of downloading the gmp .tar from the official website https://gmplib.org/#DOWNLOAD but then nothing works.
Let me say that i'm a total noob with those ./configure, make and make install stuff. I don't even know what is going on so all i did was random launching hoping something good could happen:
What i've tried after downloading the official .tar is entering the folder and go with:
./configure
make && make check && make install
I've also tried to do:
export CPPFLAGS="-I/usr/local/Cellar/gmp/include"
export LDFLAGS="-L/usr/local/Cellar/gmp/lib"
as suggested here but nothing changed. I even tried to add --prefix=/usr/local/Cellar to the ./configure command but no luck.
This all story is related to this other question of me where i was trying to go on with the issue when the ./configure was still working. Now it's like i went backwards.
Sidenote: i guess it all changed when i fired brew doctor, and brew cleanup. It must have destroyed something i made that brought me back to this state
Update 23/08/2022:
As i had to go throughout all over this again i think i have some more hint to give you for future reference, here's the list:
Install GMP via homebrew (if you have an old version of homebrew or you migrated datas between Intel Mac and M1 Mac then you need to UNINSTALL homebrew and INSTALL it all over again with all the libraries)
brew install autoconf gmp
Downloading php from source is necessary, so that you can grab the /ext/gmp directory and copy inside your current PHP version folder (for me it is currently Applications/MAMP/bin/php/php8.1.0/include/php/ext/)
You need to enter inside the gmp folder that you just copied inside Applications/MAMP/bin/php/php8.1.0/include/php/ext/gmp
The command i've launched that didn't give any errors about missing GMP was:
./configure
--with-php-config=/Applications/MAMP/bin/php/php8.1.0/bin/php-config CXXFLAGS="-I/opt/homebrew/Cellar/gmp/6.2.1_1/include
CPPFLAGS="-I/opt/homebrew/Cellar/gmp/6.2.1_1/include
LDFLAGS="-L/opt/homebrew/Cellar/gmp/6.2.1_1/lib"
launch make
launch make install
IMPORTANT NOTE: M1 is arm64 architecture and if you've installed brew correctly you should have a folder /opt/homebrew/Cellar/. Instead Intel is x86_64 and the brew folder was /usr/local/Cellar/
Old answer
Ok this was quicker then i thought but i should leave it here as a reference for everyone else which will hit the same issue.
TLDR;
You need to reinstall brew for the new architecture using this arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" and then install packages with this arch -x86_64 brew install <package>.
Credits to emonz
Long version answer:
This issue all starts with brew, i don't even know why it wasn't giving me hints about this issue until just today. When i launched brew install gmp it printed this error:
which lead me to this answer from emonz. After i finally reinstalled brew i could finally get the ./configure command to work using additional args:
./configure --with-php-config=/Applications/MAMP/bin/php/php7.3.27/bin/php-config CC="gcc -arch x86_64" CXX="g++ -arch x86_64"
So basically it is all related to the new M1 chip i guess. I still don't know what i did in the past to solve this issue w/o upgrading brew to the new arch but somehow i did it. I'll leave the question and this answer more like a guide for future comers and give them hints of what they can try to solve the issue, i wish nobody go past this pain ever again.

homebrew - upgrade php broke php 5.6 dependency

I have multiple versions of PHP installed on my localhost using homebrew:
the standard core php package (v7.3.12)
php 5.6 from exolnet/homebrew-deprecated
Now when I upgraded php to 7.3.12 recently it upgraded a dependency that php#5.6 requires and now I am getting this error:
dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
Referenced from: /usr/local/Cellar/php#5.6/5.6.40/bin/./php
Reason: image not found
[1] 83775 abort ./php
And when I navigate to /usr/local/opt/openssl/lib/ I see that I now have the upgraded libcrypto.1.1.dylib installed.
I've tried brew upgrade and reinstalling php#5.6 but no joy.
Does anyone have a suggestion? I really need both versions of php working on my localhost to continue development.
From my experience, trying to manage multiple PHP versions via homebrew is an absolute PITA, and I don't think I've ever got to the point where I can easily have both versions available side by side (until now!). Extensions are also supported, the details of which are provided later on in this answer.
That said, I have found a guide that gives some instructions on how to get this working and it works an absolute treat:
The linked guide references this method in the context of running PHP within Apache, so if that's your use case that's a nice little bonus for you too.
Now, because just posting links as answers on StackOverflow just isn't the done thing, I've detailed the main steps you need to follow in order below. Homebrew uses different paths on Apple Silicon hardware vs Intel because of course it does, so if I've missed any path changes please let me know so I can update my answer.
For anyone following this guide that doesn't yet have the prerequisites installed, ensure you have the Xcode command line tools and Homebrew installed and up to date.
If you want to check Homebrew for any issues, you can run
brew doctor
It's also never a bad idea to ensure that you have OpenSSL installed, especially if starting a fresh on macOS Monterey:
brew install openssl
So, let's get started.
Reset your environment
First, update everything then upgrade:
brew update
brew upgrade
brew cleanup
The reason for this is: "This will actually 'migrate' the core PHP packages (which are the only ones supported), but there's a bunch of symlinks utilized that could cause problems down the road, so after upgrading, we'll remove all PHP packages, to provide a fresh start"
Once you've done that, check what's actually installed:
brew list | grep php
Then remove whatever you find, for example:
brew uninstall --force php56 php56-apcu php56-opcache php56-xdebug
brew uninstall --force php70 php70-apcu php70-opcache php70-xdebug
brew uninstall --force php71 php71-apcu php71-opcache php71-xdebug
brew uninstall --force php72 php72-apcu php72-opcache php72-xdebug
brew cleanup
Double check there's nothing left:
brew list | grep php
and clean up any old configuration files:
Intel:
rm -Rf /usr/local/etc/php/*
Apple Silicon:
rm -Rf /opt/homebrew/etc/php/*
If have the exolnet/deprecated tap installed, you'll need to remove it first using
brew untap exolnet/deprecated
If you don't, you can get some weird conflicts
Add the new Tap and Install
We're then going to tap a different repository. This repository has many versions of PHP pre-built which may or may not work for you, however installation should be much faster as we don't have to compile from source.
brew tap shivammathur/php
You can then install any PHP versions you require:
brew install shivammathur/php/php#7.0
brew install shivammathur/php/php#7.1
brew install shivammathur/php/php#7.2
brew install shivammathur/php/php#7.3
brew install shivammathur/php/php#7.4
brew install shivammathur/php/php#8.0
At the time of writing, this repository has versions 5.6 through 8.1 available for installation
The php.ini files are located in the following directories:
Intel:
/usr/local/etc/php/7.0/php.ini
/usr/local/etc/php/7.1/php.ini
/usr/local/etc/php/7.2/php.ini
/usr/local/etc/php/7.3/php.ini
/usr/local/etc/php/7.4/php.ini
/usr/local/etc/php/8.0/php.ini
Apple Silicon:
/opt/homebrew/etc/php/7.0/php.ini
/opt/homebrew/etc/php/7.1/php.ini
/opt/homebrew/etc/php/7.2/php.ini
/opt/homebrew/etc/php/7.3/php.ini
/opt/homebrew/etc/php/7.4/php.ini
/opt/homebrew/etc/php/8.0/php.ini
Link your desired version
Once you've got here, close and reopen any terminal windows you have open to avoid strange path issues.
Now, these versions are installed, but not linked. To switch to PHP 7.3 for example, run the following command:
brew unlink php && brew link --overwrite --force php#7.3
And then check we have the correct version:
php -v
If we want to switch to PHP 7.4:
brew unlink php && brew link --overwrite --force php#7.4
And then check we have the correct version:
php -v
Easier Switching
If you want a faster way of switching PHP versions, check out the sPHP script from rhukster
You can install this by running:
Intel:
curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw/adc8c149876bff14a33e3ac351588fdbe8172c07/sphp.sh > /usr/local/bin/sphp
chmod +x /usr/local/bin/sphp
Apple Silicon:
curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw/adc8c149876bff14a33e3ac351588fdbe8172c07/sphp.sh > /opt/homebrew/bin/sphp
chmod +x /opt/homebrew/bin/sphp
and execute it using:
sphp 8.0
Of course, with anything like this YMMV, but this should hopefully be a good starting point and actually get you where you need to be and remove some headaches.
What about extensions?
Well I'm glad you asked. For the later versions, pecl does work. However, if you want to install xdebug for 5.6 for example, pecl throws its toys out of its pram.
There is another repository you can tap, specifically for extensions:
brew tap shivammathur/extensions
Once you've done this, it's as simple as running:
brew install xdebug#5.6
brew install xdebug#8.1
The list of available extensions is detailed in the link above. I won't include them here because it's a dynamic list and it'll soon be out of date, but most of them support 5.6 through to 8.1
Wrap up
Having followed this process myself, this is the easiest approach I'm yet to find for managing multiple PHP versions on macOS. Feel free to run brew doctor and brew cleanup at any points during the process, it can't hurt after all and might in fact help with debugging any issues you happen across. That said, my environment was an absolute mess and this tidied it up in about ten minutes. The longest step in this process for me was updating Homebrew itself.

php dyld: Library not loaded for libldap

I installed ruby on my Mac OSX High Sierra and am running into issues now with my php installation for some reason. I'm on php 7.1.
Following this (also here) Github suggestion, I tried
brew update && brew reinstall php71
While installing, it broke at
==> Pouring php#7.1-7.1.23.high_sierra.bottle.tar.gz
==> /usr/local/Cellar/php#7.1/7.1.23/bin/pear config-set php_ini /usr/local/etc/php/7.1/php.ini system
With error:
dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib
Referenced from: /usr/local/Cellar/php#7.1/7.1.23/bin/php
Reason: image not found
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall php#7.1`
Typing in php into terminal throws the same error.
Other things I've tried:
I thought perhaps it wasn't linked, so I also tried: brew unlink libldap && brew link libldap - but libldap is not supported by Homebrew
Then here, while unrelated to postgres, it does discuss the issue of libldap and says to install via brew install openldap (I guess libldap is referred to as openldap to Homebrew) - this installed fine but didn't resolve the issue
How can I fix this?
According to this issue, you need to install openldap and libiconv.
brew install openldap libiconv
I tried it and it worked for my system. I was originally missing the PHP intl extension.
It's worked for me:
brew reinstall openldap
Although I'm not sure why installing Ruby caused the issue, I solved the issue ultimately with:
According to this discussion, libldap is referred to as openldap to Homebrew. brew install openldap then ran php reinstall php71. This linked the libraries properly
The next issue was with libiconv, fortunately this is easily installed with brew install libiconv. Rerunning php install php71 solved the problem
I specifically had to uninstall the offending version. You can grab this broken version from the line that looked like this:
Referenced from: /usr/local/Cellar/php#7.1/7.1.23/bin/php
In OP's case, it was php#7.1. In my case it was php#7.3. After I ran the following based on my situation, everything worked
brew uninstall php#7.3
For those who can not resolve by brew install openldap libiconv,
try below command:
brew reinstall openldap
brew reinstall php#7.4
brew services restart php#7.4
This issue is discussed and tracked at https://github.com/Homebrew/homebrew-core/issues/32916
if you have two PHP running via brew as well a XAMPP, there could be issue in environment path in .bash_profile.
which php
Try above command to see current php path. If it not accurate, set appropriate path and comment other.
export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH
#export PATH=”/usr/local/opt/php#5.6/bin:/usr/local/opt/php#5.6/sbin:$PATH
After trying all above solutions. Finally uninstalling and reinstalling worked for me.
brew uninstall php
brew install php
For me, after running the following commands:
brew reinstall openldap
brew reinstall php#7.4
brew services restart php#7.4
I had to restart my computer for the error to stop and everything worked fine.

How to install and use PHP on macOS via brew

it seems like a little bit stupid question, but Google for one hour and cannot find it:
How to install php on macOS via brew and use in in shell.
Install is simple (if you have brew already installed):
brew install php
But after installation, when i use php -v i still see default php on mac os and not the brew's one. Shoud I Add brew php binary into PATH, bash profile, or what?
Thank you!
homebrew creates symbolic links in /usr/local/bin to pretty much every binary it installs. So the answer to your question is to add that to your path in your login profile. That will probably be $HOME/.profile and you can add a line like:
export PATH=/usr/local/bin:$PATH
Then it will be set each time you login or open a new Terminal.
So in my case, the trouble was with some access permissions on specific folders on my Mac OS, so just sharing what I learned: if it's not working, carefully examile log / error feed, there can be a hint for you!
On April 1, 2018 Homebrew discontinued the Homebrew/php tap and went with a core install approach, which means many of the extensions now must be installed with PECL. I have written a two part blog series to help with installing Apache and PHP w/ PECL on later versions of MacOS. You can find it at the link below, I hope it helps!
https://medium.com/#crmcmullen/how-to-install-php-on-macos-10-13-high-sierra-and-10-14-mojave-using-homebrew-and-pecl-ef2276db3d62
Step 1: Install Homebrew
The first step is to install Homebrew and this is a tool (package manager for macOS) that will allow us to install easily PHP and basically any other package/tools.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install PHP
To install PHP we can use the command below. The first command will automatically install the latest version of PHP which is at the current moment of writing this post version 8.
brew install php
If other versions may be preferred we can specify the PHP version and the code will look like the following.
brew install php#7.4
Step 3: The php.ini Config
The default PHP configuration should be sufficient to get started but if there are any other configurations, we can change them through the php.ini located on this path. Do note the PHP version number which in this case is version 8.
/usr/local/etc/php/8.1/php.ini
Step 4: Check if PHP is running
To check if PHP is already running we can make use of the brew services command. First, we can list the services that we have installed.
brew services list
If PHP is not started we can then run the command below to start the service in the background.
brew services start php#8.1
Step 5: Checking PHP Version
Lastly to check the PHP version do run:
php -v
By now you will have PHP running on the background process and every time you logged in to the system it will start by default. Thanks for reading and have a good try.

Categories