Whenever I open Terminal I get the following warning:
Warning: Use php instead of deprecated homebrew/php/php72
Homebrew 1.5.14 installed
PHP 7.2.4 installed
I have been researching this for quite some time now, tried a few things (reinstalling php, linking and unlinking taps) but nothing seems to have worked.
Any help would be greatly appreciated!
I fixed all my migration related issues (regarding the most-current-version 7.2) with:
# Save all old configurations, so the new packaes can recreate their versions -- eases the migration
mv /usr/local/etc/php $HOME/old-brew-php
# Uninstall ALL php related Packages (most of them homebrew/php related)
brew list | grep php | xargs brew uninstall --force
# Remove deprecated tap
brew untap homebrew/php
# Clean cache
brew cleanup
# Ensure latest brew repo HEAD
brew update
# Install latest php (php 7.2)
brew install php
pecl install xdebug
# Now copy & paste specific conf.d from your old-brew-php version if needed
# after that you may dispose of the old-brew-php folder
Older versions may be installed with the @ syntax. e.G. [email protected] or [email protected]
Thanks Blackskyliner I have tried what you suggested but I still get the same warning - no improvement sadly.
@ptisinge could you show what brew list | grep php and brew tap output?
Sure. Please see below.
brew list | grep php:
php
php71
brew tap:
homebrew/bundle
homebrew/core
homebrew/dupes
homebrew/php
homebrew/services
homebrew/versions
php71 is not in homebrew-core. You can use [email protected] instead. That should also fix your error
The thing is I need to use PHP 7.2 for what I am working on. I would have downgraded otherwise.
php == php 7.2, your php71 in your list is php 7.1.
sorry, not sure I follow.
php -v outputs this:
PHP 7.2.4 (cli) (built: Mar 29 2018 15:19:46) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
with Zend OPcache v7.2.4, Copyright (c) 1999-2018, by Zend Technologies
Hence why I believed that I was running 7.2. Am I not then?
You are, but brew list | grep php shows php php71 for you. That means you have 7.2 (php) and 7.1 (php71) installed. The error is coming from the php71 install. So if you do brew rm php71 && brew install [email protected] you will have the correct formula installed for php 7.1.
Right so running brew rm php71 && brew install [email protected] should do the trick?
Yes, that should get rid of the warning you've been seeing.
Still there sadly :-(
And what do brew list | grep php and brew tap output now?
brew list | grep php:
php
php71
[email protected]
brew tap:
homebrew/bundle
homebrew/core
homebrew/dupes
homebrew/php
homebrew/services
homebrew/versions
brew untap homebrew/php to remove the old tap
Hi, this gives me the following:
Error: No available formula with the name "homebrew/php/php72"
Please tap it and then try again: brew tap homebrew/php
I followed the steps by @Blackskyliner and also had to brew link --overwrite php to get php 7.2 on the CLI.
@ptisinge Check your .bash_profile (or .profile) for something like this:
export PATH="$(brew --prefix homebrew/php/php72)/bin:
I forgot I'd put that in a million years ago 🤦♀️
Yes if this is happening whenever you open a new terminal, it'll be something lurking in one of your shell profile files.
Thank you! It was in my .zshrc file. found it, removed it. Warning has now gone!
Thanks @Blackskyliner that did the trick for me to install php 7.2 and xdebug. One thing of note on my system (I have different versions of PHP installed to use when necessary) was that I had to run brew link php before running the pecl install xdebug so if anyone comes across this error when trying to install xdebug: pecl: command not found that was where I realized I had to symlink the php installation.
Also related, in the event anyone else needs to run multiple PHP versions, when installing xdebug or apcu via pecl it seemed to only work for whichever PHP version you have linked up (e.g. using brew link php). However, switching to another version following @Blackskyliner's recommendation below of adding a simple bash script in my bash_profile to specify which php version I am using seems to sort out any issues with xdebug and apcu on my machine. This also has the added benefit of not having to --force link previous php versions which as @Blackskyliner points out, could be a point of concern.
@Ipstenu Thank you for solving my problem !
i can't find any package for php now! i was used to have
php71-apcu
php71-xdebug
php71-redis
php71-intl
but now, after removing tap homebrew/php and ran "brew install php", i can't find any of these packages..
With the migration to Homebrew-core the php formula has stopped taking over the role of PECL. Installing redis/xdebug/apcu can (and should) be done through PECL (https://pecl.php.net/package/<PACKAGE>).
Intl is now part of the php binary though.
Same as @Ipstenu mentions...
Having a custom profile setting, that kept the warning message present:
I had the following in my .profile
. ~/.dkprofile
followed by this in .dkprofile:
PATH="$(brew --prefix homebrew/php/php71)/bin:$PATH"
At some point i also ran untap and then tap again but not sure if those 2 whould have been enough in case i wouldnt have custom profile setting.
@jceee php references the latest php, which at this moment is php 7.2, correct. Extensions are back to the php default of using pecl. Installing redis can (and should) be done through PECL (https://pecl.php.net/package/redis).
php == php 7.2 ?
i use brew install php72-redis before,
and how to install the extension now ?
@SMillerDev thanks
Hey @Blackskyliner
thanks for your update worked well. I have installed @5.6 and want to know 1. How you suggest we do the switching between the PHP versions. and 2. can xdebug work on @5.6?
For easy PHP version switch you might want to look at this tread:
https://stackoverflow.com/q/34909101/3416624
Although I’m not familiar with
xDebug sorry.
Sent from my iPhone
On 9 May 2018, at 17:46, Sam Saltis <[email protected]notifications@github.com> wrote:
thanks for your update worked well. I have installed @5.6 and want to know 1. How you suggest we do the switching between the PHP versions. and 2. can xdebug work on @5.6?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FHomebrew%2Fhomebrew-core%2Fissues%2F26107%23issuecomment-387802372&data=02%7C01%7C%7C59b1763a624c4081165708d5b5cc62f9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636614811811929781&sdata=5l6nQ%2ByxZzRR4nzw%2FmCO2IeEQB7XsPTqH2EfwpiGOk8%3D&reserved=0, or mute the threadhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAQMPGNpng4oaspFcFeqZFTq617CVHCCiks5twx1ZgaJpZM4TEw39&data=02%7C01%7C%7C59b1763a624c4081165708d5b5cc62f9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636614811811929781&sdata=bPw26OdbGr015bC3yEwkxC%2Fk%2FoYWb0tMWL3hmzrKVSw%3D&reserved=0.
@saltiss xdebug works on @5.6
@msa-dev is it done through pecl or with the core install?
You need to install xdebug with PECL after you switched to the corresponding version. (in theory /usr/local/opt/[email protected]/bin/pecl install xdebug should do the trick and install it for PHP 5.6 -- not tested by me though, since the adjustments to the php packages were made regarding pear and pecl linking in https://github.com/Homebrew/homebrew-core/pull/26137 but it should work this way)
Which version you will need to install through pecl, regarding php 5.x and 7.x versions, see: https://github.com/Homebrew/homebrew-core/issues/26108#issuecomment-378234780 -- My reported bugs in that comment should be solved through the pull request I linked above and the install should not fail.
To the switching question:
I use simple bash functions to switch between versions 'globally'
enable_php56(){
export PATH=/usr/local/opt/[email protected]/bin:$PATH
}
enable_php71(){
export PATH=/usr/local/opt/[email protected]/bin:$PATH
}
enable_php72(){
export PATH=/usr/local/opt/php/bin:$PATH
}
Alternatively you could also use aliases in your bashrc/zshrc
alias php56=/usr/local/opt/[email protected]/bin/php
alias php71=/usr/local/opt/[email protected]/bin/php
alias php72=/usr/local/opt/php/bin/php
Another possibility would be to symlink them to /usr/local/bin as php56, php71 and php72 -- Just keep in mind that it's YOUR setup to alias them then without support by brew. (aka when php is 7.3 and a seperate 7.2 package will be released you will need to adjust YOUR setup [aliases or bash functions] and manually created links)
@Blackskyliner thanks again for your detailed response. This all worked..I thought Id also add that if people want to install memcached in the same way the version is memcached-2.2.0
@msa-dev I've done exactly what @Blackskyliner said, this worked like a charm.
These steps helped me avoid the xdebug installation issue.
I did this:
# install latest php
brew install php
# install latest(!) xdebug
pecl install xdebug
output of php -v
PHP 7.2.5 (cli) (built: Apr 26 2018 12:07:32) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
with Zend OPcache v7.2.5, Copyright (c) 1999-2018, by Zend Technologies
Then install an older version of php (I needed 5.6)
# unlink php
brew unlink php
# install php 5.6
brew install [email protected]
brew link [email protected] --force
# install the last version supported for php 5.6
pecl install xdebug-2.5.5
output of php -v
PHP 5.6.36 (cli) (built: Apr 26 2018 22:02:57)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
That worked for me
Forced linking is, as far as I got it, not really seen as a 'resolution' to a problem in this tracker. Becasue force linking may raise hard to debug issues for the maintainer in case of problems on your side, I guess...
Was calling the correct php version binary not enough to not run into any bugs?
(e.g. setting PATH or calling the correct binary path absolute)
My feelings for this whole issue would be to integrate php versioning for @ versions a bit like CentOS Remi Repository does. Installing corresponding aliased phpXY links in /usr/local/bin -- A solution also mentioned by me above. But I guess it's not the 'style' of how brew does it's versioning.
@Blackskyliner I hadn't even thought of using something like the simple bash functions you mention above, that alleviates all issues with having to use --force when relinking a different php version. Thanks for that! I'll edit my previous response about using multiple php versions.
Most helpful comment
I fixed all my migration related issues (regarding the most-current-version 7.2) with:
Older versions may be installed with the
@syntax. e.G.[email protected]or[email protected]