Files
mkdocs/docs/macos/webserver/php73.md
2020-01-25 06:47:22 +01:00

167 lines
3.7 KiB
Markdown

# PHP 7.3
### Changer de version de PHP:
```bash
$ brew unlink php@7.3 && brew link --force --overwrite php@5.6
```
On installe un petit utilitaire [PHP Switcher Script](https://gist.github.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2)
```bash
$ curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw > /usr/local/bin/sphp
$ chmod +x /usr/local/bin/sphp
https://gist.github.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw/b51e5f561dc6492249ac167813b9b40dcdd72bd0/sphp.sh
```
Ensuite pour changer de version:
```bash
$ sphp 7.3
```
Par exemple, pour passer de 7.2.13. à 7.3.0_1:
```bash
$ sphp 7.3
Switching to php@7.3
Switching your shell
Unlinking /usr/local/Cellar/php@7.2/7.2.13... 25 symlinks removed
Unlinking /usr/local/Cellar/php/7.3.0_1... 0 symlinks removed
Linking /usr/local/Cellar/php/7.3.0_1... 24 symlinks created
You will need sudo power from now on
Switching your apache conf
Password:
Restarting apache
PHP 7.3.0 (cli) (built: Jan 3 2019 10:08:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.0, Copyright (c) 1999-2018, by Zend Technologies
All done!
```
Il y a un autre utilitaire (<u>brew-php-switcher</u>):
```bash
$ brew info brew-php-switcher
brew-php-switcher: stable 2.0, HEAD
Switch Apache / Valet / CLI configs between PHP versions
https://github.com/philcook/php-switcher
Not installed
```
### Extensions:
#### Liste des extensions (Homebrew):
```bash
$ brew search php73
```
#### Installer des extensions (avec [PECL](https://pecl.php.net)):
Requiert autoconf: `brew install autoconf`
```bash
$ pecl uninstall -r xdebug
$ pecl install xdebug
$ pecl install yaml
$ pecl install redis
$ pecl install apcu
$ pecl install memcached
$ pecl install imagick
# Pour une version spécifique:
$ pecl install xdebug-2.7.0beta1
```
Pour les activer, créez un fichier de configuration dans `/usr/local/etc/php/7.3/conf.d/`
```bash
bruno@silverbook:/usr/local/etc/php/7.3/conf.d$ l
total 32
drwxr-xr-x 6 bruno admin 192 4 jan 19:32 .
drwxr-xr-x 9 bruno admin 288 3 jan 19:34 ..
-rw-r--r-- 1 bruno admin 72 4 jan 16:09 ext-opcache.ini
-rw-r--r-- 1 bruno admin 172 4 jan 18:58 ext-xdebug.ini
-rw-r--r-- 1 bruno admin 81 4 jan 18:43 ext-yaml.ini
-rw-r--r-- 1 bruno admin 87 13 déc 07:12 fix-jit.ini
bruno@silverbook:/usr/local/etc/php/7.3/conf.d$ nano ext-xdebug.ini
[xdebug]
zend_extension="/usr/local/lib/php/pecl/20180731/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
```
#### Installer une extension (depuis les sources):
```bash
# Installation de ssh2:
$ brew install libssh2
$ cd ~/Downloads
$ git clone https://git.php.net/repository/pecl/networking/ssh2.git
$ cd ssh2
$ phpize
$ ./configure
$ make
$ make install
$ cd /usr/local/etc/php/7.3/conf.d
$ nano ext-ssh2.ini
Ajouter au fichier:
extension="ssh2.so"
```
```bash
# Installation de xdebug:
$ wget http://xdebug.org/files/xdebug-x.x.x.tgz
$ tar -xzvf xdebug-x.x.x.tgz
$ cd xdebug-x.x.x
$ phpize
$ ./configure
$ make
$ make install
```
### Erreurs:
#### Warning: preg_replace(): JIT compilation failed: no more memory in
Il s'agit d'un [bug](https://bugs.php.net/bug.php?id=77260) connu de PHP 7.3.
2 solutions:
- désinstaller php 7.3
`$ brew uninstall php@7.3`
- désactiver la compilation PCRE JIT dans le php.ini
`pcre.jit=0`
Pour désactiver la compilation PCRE JIT, on peut aussi créer un fichier `fix-jit.ini` dans `/usr/local/etc/php/7.3/conf.d`et y ajouter:
```php
; My php.ini settings
; Fix for PCRE "JIT compilation failed" error
[Pcre]
pcre.jit=0
```