Skip to content

Commit

Permalink
Add --2.2 flag, update installer docs, update installer checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Apr 29, 2022
1 parent ed55148 commit 0a51b6f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
10 changes: 7 additions & 3 deletions templates/download.html.twig
Expand Up @@ -25,7 +25,7 @@
To automate the installation, use <a href="/doc/faqs/how-to-install-composer-programmatically.md" title="See the instructions on how to install Composer programmatically" aria-label="See the instructions on how to install Composer programmatically">the guide on installing Composer programmatically</a>.
</p>
<pre class="installer">php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"</pre>

Expand Down Expand Up @@ -71,6 +71,10 @@ php -r "unlink('composer-setup.php');"</pre>
target release. Example:</p>
<code>php composer-setup.php --version=1.0.0-alpha8</code>

<h3>--preview, --snapshot, --1 (EOL), --2, --2.2 (LTS)</h3>
<p>Select a specific version channel instead of the default latest stable. See "Download channels" below for more details. Example:</p>
<code>php composer-setup.php --2.2</code>

<h3>--help</h3>
<p>The installer provides more options for specific environments, use the
<code>--help</code> option to see all of them.</p>
Expand All @@ -84,8 +88,8 @@ php -r "unlink('composer-setup.php');"</pre>
For snapshot builds, which are done from the latest Composer commit,
you can use the <code>--snapshot</code> flag.<br>
To programmatically install specific major versions you can use the
<code>--1</code> or <code>--2</code> flag. Example:</p>
<code>php composer-setup.php --preview</code>
<code>--1</code> or <code>--2</code> flag. To select the latest 2.2 LTS
you can use <code>--2.2</code>.</p>

<h2>Manual Download</h2>
<p>If you prefer to download the phar manually, here are the available versions:</p>
Expand Down
14 changes: 10 additions & 4 deletions web/installer
Expand Up @@ -50,8 +50,7 @@ function process($argv)
// Determine ANSI output from --ansi and --no-ansi flags
setUseAnsi($argv);

$help = in_array('--help', $argv);
$help = $help || in_array('-h', $argv);
$help = in_array('--help', $argv) || in_array('-h', $argv);
if ($help) {
displayHelp();
exit(0);
Expand All @@ -69,6 +68,8 @@ function process($argv)
$channel = '1';
} elseif (in_array('--2', $argv)) {
$channel = '2';
} elseif (in_array('--2.2', $argv)) {
$channel = '2.2';
}
$disableTls = in_array('--disable-tls', $argv);
$installDir = getOptValue('--install-dir', $argv, false);
Expand All @@ -92,6 +93,10 @@ function process($argv)
}

if ($ok || $force) {
if ($channel === '1' && !$quiet) {
out('Warning: You forced the install of Composer 1.x via --1, but Composer 2.x is the latest stable version. Updating to it via composer self-update --stable is recommended.', 'error');
}

$installer = new Installer($quiet, $disableTls, $cafile);
if ($installer->run($version, $installDir, $filename, $channel)) {
showWarnings($warnings);
Expand Down Expand Up @@ -121,8 +126,9 @@ Options
--install-dir="..." accepts a target installation directory
--preview install the latest version from the preview (alpha/beta/rc) channel instead of stable
--snapshot install the latest version from the snapshot (dev builds) channel instead of stable
--1 install the latest stable Composer 1.x version
--1 install the latest stable Composer 1.x (EOL) version
--2 install the latest stable Composer 2.x version
--2.2 install the latest stable Composer 2.2.x (LTS) version
--version="..." accepts a specific version to install instead of the latest
--filename="..." accepts a target filename (default: composer.phar)
--disable-tls disable SSL/TLS security for file downloads
Expand Down Expand Up @@ -702,7 +708,7 @@ class Installer
$result = $this->install($version, $channel);

// in case --1 or --2 is passed, we leave the default channel for next self-update to stable
if (is_numeric($channel)) {
if (1 === preg_match('{^\d+$}D', $channel)) {
$channel = 'stable';
}

Expand Down

0 comments on commit 0a51b6f

Please sign in to comment.