OSDN Git Service

Regular updates
[twpd/master.git] / composer.md
index a838f3f..e73c3a3 100644 (file)
@@ -10,7 +10,7 @@ description: |
   Basic guide on how to use Composer, the PHP Package manager.
 ---
 
-All composer commands, depending on your install, may need to use `php composer.phar` in the install folder for composer, instead of plain `composer`.
+All composer commands, depending on your install, may need to use `php composer.phar` in the install folder for composer, instead of global/plain `composer`.
 
 ### Installing dependencies
     
@@ -49,12 +49,27 @@ This command changes only the `composer.lock` file.
 
 | Command                          | Description                                                 |
 | ---                              | ---                                                         |
-| `composer require vendor/package`.      | Adds `package` from `vendor` to composer.json's `require` section and installs it             |
+| `composer require vendor/package`      | Adds `package` from `vendor` to composer.json's `require` section and installs it             |
 | ---                              | ---                                                         |
 | `composer require vendor/package --dev` | Adds `package` from `vendor` to composer.json's `require-dev` section and installs it.            |
 
 This command changes both the `composer.json` and `composer.lock` files.
 
+### Passing versions
+
+| Command                                         | Description                              |
+| ----------------------------------------------- | ---------------------------------------- |
+| `composer require vendor/pkg "1.3.2"`           | Installs `1.3.2`                         |
+| `composer require vendor/pkg ">=1.3.2"`         | Above or equal `1.3.2`                   |
+| `composer require vendor/pkg "<1.3.2"`          | Below `1.3.2`                            |
+| `composer require vendor/pkg "1.3.*"`           | Latest of `>=1.3.0 <1.4.0`               |
+| `composer require vendor/pkg "~1.3.2"`          | Latest of `>=1.3.2 <1.4.0`               |
+| `composer require vendor/pkg "~1.3"`            | Latest of `>=1.3.0 <2.0.0`               |
+| `composer require vendor/pkg "^1.3.2"`          | Latest of `>=1.3.2 <2.0.0`               |
+| `composer require vendor/pkg "^1.3"`            | Latest of `>=1.3.0 <2.0.0`               |
+| `composer require vendor/pkg "^0.3.2"`          | Latest of `>=0.3.0 <0.4.0` (for pre-1.0) |
+| `composer require vendor/pkg "dev-BRANCH_NAME"` | From the branch `BRANCH_NAME`            |
+
 ### Removing packages
 
 | Command                   | Description                                                 |
@@ -62,3 +77,9 @@ This command changes both the `composer.json` and `composer.lock` files.
 | `composer remove vendor/package` | Removes `vendor/package` from composer.json and uninstalls it      |
 
 This command changes both the `composer.json` and `composer.lock` files.
+
+### Verifying
+
+| Command                      | Description                                                                |
+| ---------------------------- | -------------------------------------------------------------------------- |
+| `composer outdated --direct` | Show only packages that are outdated directly required by the root package |