# php-composer & php7



## Sato (Oct 11, 2017)

Hi,

I'm a php developer and i've switch on FreeBSD.
When i want to install php-composer is want to install php 5.6, i dont want it, i want php7 or higher.

This is possible to make this ?

Thomas.


----------



## SirDice (Oct 11, 2017)

Yes, it's possible, but you will need to build from ports. The default PHP version is 5.6 so all official packages are based on that. If you build from ports you can deviate from the default by setting this in /etc/make.conf:

```
DEFAULT_VERSIONS+= php=70
```
See /usr/ports/Mk/bsd.default-versions.mk for more options and versions.


----------



## Sato (Oct 11, 2017)

SirDice Wow amazing i've install php 7.1, much easier compar to Linux...
But when php 7.2 arrived i just edit make.conf ? and after ?

If i want to install PHP extension what is the procedure ?

In linux i find in repos php-intl for example.

Thx a lot


----------



## SirDice (Oct 11, 2017)

Sato said:


> But when php 7.2 arrived i just edit make.conf ? and after ?


Yes, that's the idea.



> If i want to install PHP extension what is the procedure ?


Just go to the extension you want and build it. It will automatically depend on the specified version from make.conf.



Sato said:


> In linux i find in repos php-intl for example.


Not exactly sure which one that is but there's a convenient port that installs a couple of the most common extensions: lang/php71-extensions.


----------



## Sato (Oct 11, 2017)

Ok thanks, I have installed the PHP extensions.
In fact in FreeBSD I can have the latest package compare for example to Debian stop to PHP 7.0


----------



## SirDice (Oct 11, 2017)

The "problem" with most Linux distributions is that their packages are depending on the version of the distribution. So Debian 6 has PHP5.6 for example, Debian 7 PHP 7.0 [*]. On FreeBSD the ports and the OS are two separate entities and all versions of FreeBSD use the exact same ports tree. So it's perfectly possible to have FreeBSD 10.4 with PHP 7.1 and FreeBSD 11.1 with PHP 5.6.

[*] Not exactly sure if those versions are correct, but you get the idea.


----------



## Oliver Schonrock (Dec 1, 2017)

SirDice said:


> On FreeBSD the ports and the OS are two separate entities and all versions of FreeBSD use the exact same ports tree. So it's perfectly possible to have FreeBSD 10.4 with PHP 7.1 and FreeBSD 11.1 with PHP 5.6.



Indeed. We have been using FreeBSD for 15 years in our production facility, exactly because building from ports gave us such great control over the php version with all it's extensions (apart from just being a kickass OS).

However, with the (relatively) recent change to "binary packages preferred" approach, we have switched to using pkg for building our servers, rather than ports. This has been mostly fine (and much quicker!), however with the upgrade to php7* and the default php version on FreeBSD remaining at php56, we have ended up building some (mainly pecl) extensions from ports (using the make.conf default version setting).

This quickly gets messy, as a "pkg upgrade" now "breaks" and tries to install php56 again. This is the main reason we have not yet upgraded our production machines to php7.

Is there any better way? The ones we are aware of:

1. run a poudriere server to build our "custom" packages and then pkg install them on all the production machines. (We suspect this just moves the same problem to the poudriere machine ? unless we go back to building everything from source on there..)

2. go back to building all our machines from source.

3. patiently wait for the FreeBSD ports team to change its default version to php7*  (probably php73 by the time we get there?)

Is there any plan for 3.? I have not seen any discussion anywhere.

Don't get me wrong, I am not complaining, just wondering what the best path is.

Many Thanks


----------



## SirDice (Dec 1, 2017)

I can highly recommend setting up a build server with Poudriere. Build everything you need there with the versions you want and simply point a server's pkg(8) to your repository. Make sure to disable the standard FreeBSD repository so you'll never run into conflicts.

As for updating the build server itself, just point pkg(8) to the package directory (you can use file:// URLs) you just built and off you go.


----------



## OlivierW (Dec 2, 2017)

Oliver Schonrock said:


> 1. run a poudriere server to build our "custom" packages and then pkg install them on all the production machines. (We suspect this just moves the same problem to the poudriere machine ? unless we go back to building everything from source on there..)



It's what we have been using: building PHP 7.0 and the extensions we need (even stuff like phpmyadmin) with poudriere.
I don't understand what you meant with: "We suspect this just moves the same problem to the poudriere machine ?".


----------

