# Composer:



### Composer s'installe avec Homebrew :

(nécessite php avec l'extension phar)

```bash
$ brew install composer

$ php composer --version
Composer version 1.6.3 2018-01-31 16:28:17
```

Fichier config:`~/.composer/config.json`



### Pour installer une application:

on se positionne dans son dossier où l'on trouve 2 fichiers:

- composer.json
- composer.lock

```bash
$ composer install

# Sur DSM 6
$ composer.phar install
```



Si erreur, mettre à jour:

```bash
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for friendsofphp/php-cs-fixer v2.2.6 -> satisfiable by friendsofphp/php-cs-fixer[v2.2.6].
    - friendsofphp/php-cs-fixer v2.2.6 requires php ^5.3.6 || >=7.0 <7.2 -> your PHP version (7.2.3) does not satisfy that requirement.
```



### Pour mettre à jour:

```bash
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 62 installs, 0 updates, 0 removals

- Installing symfony/process (v4.0.6): Downloading (100%)
- Installing klaussilveira/gitter (0.2.0): Downloading (100%)

### 

Writing lock file
Generating autoload files
```

Juste pour tester, aucune modification n'est faite:

```bash
$ composer update --dry-run --profile --verbose
```

### Liste des commandes

```bash
$ composer list
```

### Aide:

```bash
$ composer —help
```

### Affiche ce qui a été installé:

```bash
$ composer show
```



https://coderwall.com/p/ma_cuq/using-composer-to-manage-global-packages

https://akrabat.com/global-installation-of-php-tools-with-composer/

