# Installation



### 1. Installer wp-cli sur osx

```bash
$ brew install wp-cli
```



```bash
$ brew install wp-cli-completion

# => /opt/homebrew/Cellar/wp-cli-completion/2.11.0/etc/bash_completion.d/wp

# Bash: /opt/homebrew/etc/bash_completion.d

# Zsh: /opt/homebrew/share/zsh-completions
# Bash: /opt/homebrew/share/bash-completion/completion

[[ -r $(brew --prefix)/Cellar/wp-cli-completion/2.11.0/etc/bash_completion.d/wp ]] && source $(brew --prefix)/Cellar/wp-cli-completion/2.11.0/etc/bash_completion.d/wp

```



#### Installer le script [**wp-cli bash completion**](https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash)

- Télécharger le script et le copier dans le dossier Home
- Ajouter source ~/wp-completion.bash au .bash_profile

```bash
echo "source ~/wp-completion.bash" >> .bash_profile
```


Taper wp<espace><tab 2x> pour voir la liste des commandes disponibles.



### 2. Installer wp-cli sur ovh mutualisé

Télécharger le fichier **wp-cli.phar**
https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
L'envoyer sur ovh dans `/opt/bin`
puis

```bash
chmod +x wp-cli.phar
ln -s wp-cli.phar wp
```

Aller dans le dossier wordpress pour tester wp-cli

```bash
cd ~/www/wordpress
~/www/wordpress $ wp plugin list
+---------------------------------------------+----------+-----------+---------+
| name                                        | status   | update    | version |
+---------------------------------------------+----------+-----------+---------+
| add-from-server                             | inactive | none      | 3.3.3   |
| admin-post-navigation                       | active   | none      | 2.1     |
| akismet                                     | active   | none      | 4.0.8   |
| wp-retina-2x-pro                            | active   | available | 5.2.9   |
| wp-super-cache                              | inactive | none      | 1.6.3   |
| wordpress-seo                               | active   | none      | 7.9.1   |
+---------------------------------------------+----------+-----------+---------+
```



### 3. Installer wp-cli sur un NAS Synology

```bash
# !/usr/bin/env bash

# Télécharger
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

# Test
php wp-cli.phar --info

chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

# Test
wp --info
```



Par défaut, wp se lance avec php 5.6 (d'origine Synology).

```bash
$ wp --info
OS:	Linux DS916 3.10.105 #23739 SMP Tue Jul 10 00:16:03 CST 2018 x86_64
Shell:	/opt/bin/bash
PHP binary:	/usr/bin/php
PHP version:	5.6.11
php.ini used:	/etc/php/php.ini
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/usr/local/bin
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version:	2.0.0
```



Pour le lancer avec PHP70 (paquet Synology), 

- Créer un script **wp.sh** dans `/usr/local/bin`
- Ajouter le contenu suivant:

```bash
#!/bin/bash

# Running wp-cli on Synology NAS

# Add '-d extension=phar.so' to use wp-cli.phar with php70. No needed with php or php56
php70 -d extension=phar.so wp-cli.phar $*
```

- Rendre le script exécutable et le renommer:

```bash
$ chmod +X wp.sh

$ mv wp.sh wp
```

- Utilisation:

```bash
$ wp --info
OS:	Linux 3.10.105 #23739 SMP Tue Jul 10 00:16:03 CST 2018 x86_64
Shell:	/opt/bin/bash
PHP binary:	/volume1/@appstore/PHP7.0/usr/local/bin/php70
PHP version:	7.0.30
php.ini used:	/usr/local/etc/php70/php.ini
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/usr/local/bin
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version:	2.0.0
```



### 4. Installer wp-cli sur sur-le-sentier.fr

```bash
# !/usr/bin/env bash

# Télécharger
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

# Test
php wp-cli.phar --info

chmod +x wp-cli.phar
sudo mv wp-cli.phar wp

# Test
./wp --info

# Ajouter dans .bash_aliases
alias wp='$HOME/wp'

# Installer les TAB completions
curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/v2.6.0/utils/wp-completion.bash
echo "source ~/wp-completion.bash" >> .bashrc
```

```bash
# Mise-à-jour
wp cli update --nightly
wp cli update
```



https://make.wordpress.org/cli/handbook/references/shell-friends/

