# PHP update to 5.6



## dave (Mar 5, 2015)

`# pkg info php5\* > ~/installed-php-ports-list`
`# pkg update && pkg upgrade`

```
[...snip...]
Fetching php56-5.6.6.txz: 100%    2 MiB 655.1kB/s    00:03
Checking integrity... done (1 conflicting)
pkg: Cannot solve problem using SAT solver:
dependency rule: package php5(r) depends on: php5(l)pecl-APC(l)
dependency rule: package php5(r) depends on: php5(l)php5-extensions(l)
conflict rule: The following packages conflict with each other: php5-5.4.38(r), php56-5.6.6(r)
dependency rule: package php5(r) depends on: php5(l)pecl-geoip(l)
dependency rule: package php5(r) depends on: php5(l)pecl-ssh2(l)
conflict rule: The following packages conflict with each other: php5-5.4.38(r), php5-5.4.38(r)
upgrade rule: upgrade local php5-5.4.37 to remote php5-5.4.38
dependency rule: package php5(r) depends on: php5(l)php5-bz2(r)
dependency rule: package php5(r) depends on: php5(l)php5-bz2(l)
dependency rule: package php5(r) depends on: php5(l)php5-ctype(r)
dependency rule: package php5(r) depends on: php5(l)php5-ctype(l)
dependency rule: package php5(r) depends on: php5(l)php5-curl(r)
dependency rule: package php5(r) depends on: php5(l)php5-curl(l)
dependency rule: package php5(r) depends on: php5(l)php5-dom(r)
dependency rule: package php5(r) depends on: php5(l)php5-dom(l)
dependency rule: package php5(r) depends on: php5(l)php5-fileinfo(r)
dependency rule: package php5(r) depends on: php5(l)php5-fileinfo(l)
dependency rule: package php5(r) depends on: php5(l)php5-filter(r)
dependency rule: package php5(r) depends on: php5(l)php5-filter(l)
dependency rule: package php5(r) depends on: php5(l)php5-gd(r)
dependency rule: package php5(r) depends on: php5(l)php5-gd(l)
dependency rule: package php5(r) depends on: php5(l)php5-hash(r)
dependency rule: package php5(r) depends on: php5(l)php5-hash(l)
dependency rule: package php5(r) depends on: php5(l)php5-iconv(r)
dependency rule: package php5(r) depends on: php5(l)php5-iconv(l)
dependency rule: package php5(r) depends on: php5(l)php5-imap(r)
dependency rule: package php5(r) depends on: php5(l)php5-imap(l)
dependency rule: package php5(r) depends on: php5(l)php5-json(r)
dependency rule: package php5(r) depends on: php5(l)php5-json(l)
dependency rule: package php5(r) depends on: php5(l)php5-mbstring(r)
dependency rule: package php5(r) depends on: php5(l)php5-mbstring(l)
dependency rule: package php5(r) depends on: php5(l)php5-mcrypt(r)
dependency rule: package php5(r) depends on: php5(l)php5-mcrypt(l)
dependency rule: package php5(r) depends on: php5(l)php5-mysql(r)
dependency rule: package php5(r) depends on: php5(l)php5-mysql(l)
dependency rule: package php5(r) depends on: php5(l)php5-mysqli(r)
dependency rule: package php5(r) depends on: php5(l)php5-mysqli(l)
dependency rule: package php5(r) depends on: php5(l)php5-openssl(r)
dependency rule: package php5(r) depends on: php5(l)php5-openssl(l)
dependency rule: package php5(r) depends on: php5(l)php5-pdo(r)
dependency rule: package php5(r) depends on: php5(l)php5-pdo(l)
dependency rule: package php5(r) depends on: php5(l)php5-pdo_mysql(r)
dependency rule: package php5(r) depends on: php5(l)php5-pdo_mysql(l)
dependency rule: package php5(r) depends on: php5(l)php5-pdo_sqlite(r)
dependency rule: package php5(r) depends on: php5(l)php5-pdo_sqlite(l)
dependency rule: package php5(r) depends on: php5(l)php5-phar(r)
dependency rule: package php5(r) depends on: php5(l)php5-phar(l)
dependency rule: package php5(r) depends on: php5(l)php5-posix(r)
dependency rule: package php5(r) depends on: php5(l)php5-posix(l)
dependency rule: package php5(r) depends on: php5(l)php5-session(r)
dependency rule: package php5(r) depends on: php5(l)php5-session(l)
dependency rule: package php5(r) depends on: php5(l)php5-simplexml(r)
dependency rule: package php5(r) depends on: php5(l)php5-simplexml(l)
dependency rule: package php5(r) depends on: php5(l)php5-soap(r)
dependency rule: package php5(r) depends on: php5(l)php5-soap(l)
dependency rule: package php5(r) depends on: php5(l)php5-sockets(r)
dependency rule: package php5(r) depends on: php5(l)php5-sockets(l)
dependency rule: package php5(r) depends on: php5(l)php5-sqlite3(r)
dependency rule: package php5(r) depends on: php5(l)php5-sqlite3(l)
dependency rule: package php5(r) depends on: php5(l)php5-tokenizer(r)
dependency rule: package php5(r) depends on: php5(l)php5-tokenizer(l)
dependency rule: package php5(r) depends on: php5(l)php5-xml(r)
dependency rule: package php5(r) depends on: php5(l)php5-xml(l)
dependency rule: package php5(r) depends on: php5(l)php5-xmlreader(r)
dependency rule: package php5(r) depends on: php5(l)php5-xmlreader(l)
dependency rule: package php5(r) depends on: php5(l)php5-xmlwriter(r)
dependency rule: package php5(r) depends on: php5(l)php5-xmlwriter(l)
dependency rule: package php5(r) depends on: php5(l)php5-zip(r)
dependency rule: package php5(r) depends on: php5(l)php5-zip(l)
dependency rule: package php5(r) depends on: php5(l)php5-zlib(r)
dependency rule: package php5(r) depends on: php5(l)php5-zlib(l)
cannot install package php5, remove it from request? [Y/n]:
pkg: cannot find php5 in the request
pkg: cannot solve job using SAT solver
Checking integrity... done (0 conflicting)
Conflicts with the existing packages have been found.
One more solver iteration is needed to resolve them.
```

???


----------



## derekschrock (Mar 5, 2015)

Did you try setting the origin of lang/php5 to lang/php56?

`pkg set -o lang/php5:lang/php56
pkg upgrade`


----------



## quamenzullo (Mar 17, 2015)

Hi,

I'm into the same problem (although it did show up later, only the next time I tried to upgrade), so I tried your suggestion, but it didn't help unfortunately. Or it is not enough, I think, because now the upgrade to php5.6 seems possible, but all php extensions remain stuck at 5.4.

Is it necessary to run a similar command for lang/php5-extensions?

dave, did you solve the problem?


----------



## johnjaylward (Mar 18, 2015)

I solved it by manually upgrading each php package affected by a conflict:

`pkg upgrade php5-bz2`

`pkg upgrade php5-ctype`

etc etc


----------



## quamenzullo (Mar 18, 2015)

Thanks, but I've installed php5 (and php5-*) with `portmaster`, which does not want to upgrade it to 5.6, it stays on 5.4.

`pkg` would upgrade it to 5.6, indeed. Don't know why `pkg` has already the 5.6 version while `portmaster` not.


----------



## quamenzullo (Mar 18, 2015)

Is there a way to tell `portmaster` to give up with the old 5.4 version? `pkg set -o lang/php5:lang/php56` is fine for `pkg`, but `portmaster` obviously ignores it.


----------



## kpa (Mar 18, 2015)

The PHP version 5.6 ports are not seen as updates to the older PHP 5.4 ports because they are different ports in the tree, that's why ports-mgmt/portmaster will stick to updating only what is installed and only newer versions of the same ports. What you want do is to use the -o option of portmaster(8) that tells it to replace a port with another:

`portmaster -o lang/php56 php5-5.4.38`


----------



## quamenzullo (Mar 19, 2015)

Sorry to come back with other questions, but there's still something I don't understand: why does /usr/ports/UPDATING mentions that:


> The default PHP version has been updated from 5.4 to 5.6.



Question 1. What does it implies in terms of packages' management? Is it just an information, without any consequence? I may just keep using the 5.4 version without trying to upgrade to 5.6?

In the case of mysql, for instance, there was also a change recently, that lead to upgrade to the next version.

Question 2. Why isn't it the case with php too?

Notice that /usr/ports/UPDATING tells exactly the very same thing about mysql as about php:


> The default MySQL version has been updated from 5.5 to 5.6.


(though in the case of mysql, there were some more hints about how to keep 5.5 as default etc.)

From these informations, and from the content of the matching directories, I don't know how I can understand that the behavior will be different for php and mysql:

```
/usr/ports # ls databases/mysql5<TAB>
mysql51-client/  mysql51-scripts/ mysql51-server/  mysql55-client/  mysql55-server/  mysql56-client/  mysql56-server/
/usr/ports # ls lang/php5<TAB>
php5-extensions/  php53-extensions/ php55-extensions/ php56-extensions/
php5/  php53/  php55/  php56/
```
In both cases, the 55 and 56 versions show up in different subdirectories.


----------



## kpa (Mar 19, 2015)

The default versions are set in /usr/ports/Mk/bsd.default-versions.mk. They are used when building ports and a port requests PHP as its dependency but doesn't set the version explicitly, the current default of 5.6 would pull in the lang/php56 port. When updating existing installed packages the default still applies and if you want to keep using the older PHP54 as the PHP port you have to set DEFAULT_VERSIONS=php=5.4 in your /etc/make.conf.

When using binary packages it depends on which default version was in effect when the packages were built. If they were built when PHP 5.4 was the default they will be unusable with anything that wants 5.6 version of PHP:

I have to rant here a bit because there's a great confusion and lack of common pratices in the area of port naming here. The PERL ports are using names like lang/perl5.16, lang/perl5.18 and so on and there is no lang/perl5 port anymore, the default version just selects the matching port. The PHP ports however still have the lang/php5 port that is the PHP54 port and it is no longer the default but still many people believe that the lang/php5 is the default one because that's how it used to be but of course the default PHP56 port is now the lang/php56 port. This gives a rather poor impression of the ports system when it comes to setting and following policies and practices and it's really a result of individual developers and teams doing what they think is best when there are no clear guidelines written down to follow.


----------



## quamenzullo (Mar 20, 2015)

Many thanks for the explanations! Now I understand clearly why `portmaster` sticks to 5.4. Also, I guess that the next time `pkg` will upgrade nginx, the new nginx will require the 5.6 to work, so I'll have to upgrade php to 5.6 by installing lang/php56 before running the new nginx.
Many thanks again, I think this will help me the next times there are version's upgrades.


----------



## unixowl (Oct 19, 2015)

quamenzullo said:


> Is there a way to tell `portmaster` to give up with the old 5.4 version? `pkg set -o lang/php5:lang/php56` is fine for `pkg`, but `portmaster` obviously ignores it.


There is a quick solution for this:

```
# portmaster -o lang/php56 php5-5.4.45
# pkg info | grep php | grep 5.4 | awk '{print $1}' | awk -F '-5.4' '{print "whereis "$1}' | sh | awk -F ': /usr/ports/' '{print "portmaster -y -D -o "$2" "$1}' | sed -e "s@/php5-@/php56-@" -e 's@$@-5.4.45@' | sh
# portmaster -d -y pecl
```
Replace 5.4.45 in the sed(1) with the exact version of php you have installed.
It goes through all installed php5 modules and upgrades them to php56.
It's dirty, but does the job. Hope it helps to someone.


----------

