Skip to content

Commit ccdc6ca

Browse files
committed
Merged pull request #1287
2 parents c5d1772 + 850d70d commit ccdc6ca

38 files changed

+839
-63
lines changed

downloads-get-instructions.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
$file = 'unknown';
3+
$latestPhpVersion = '8.4';
4+
5+
if (!isset($options)) {
6+
$options = [
7+
'os' => '',
8+
'usage' => '',
9+
'version' => '',
10+
];
11+
}
12+
13+
if ($options['os'] === 'windows') {
14+
if ($options['osvariant'] === 'windows-wsl-debian') {
15+
$options['os'] = 'linux';
16+
$options['osvariant'] = 'linux-debian';
17+
}
18+
if ($options['osvariant'] === 'windows-wsl-ubuntu') {
19+
$options['os'] = 'linux';
20+
$options['osvariant'] = 'linux-ubuntu';
21+
}
22+
}
23+
if ($options['os'] === 'osx' || $options['os'] === 'windows') {
24+
if ($options['version'] === 'default') {
25+
$options['version'] = $latestPhpVersion;
26+
}
27+
}
28+
29+
if (in_array($options['usage'], ['fw-drupal', 'fw-laravel', 'fw-symfony', 'fw-wordpress'])) {
30+
$file = "{$options['usage']}";
31+
$options['os'] = null;
32+
}
33+
34+
$multiversion = false;
35+
36+
if (array_key_exists('multiversion', $options)) {
37+
$multiversion = $options['multiversion'] === 'Y';
38+
}
39+
40+
$source = false;
41+
42+
if (array_key_exists('source', $options)) {
43+
if ($options['source'] === 'Y') {
44+
$source = $options['source'] === 'Y';
45+
}
46+
}
47+
48+
switch ($options['os']) {
49+
case 'linux':
50+
$defaultOrCommunity = ($options['version'] !== 'default' || $multiversion) ? 'community' : 'default';
51+
if ($defaultOrCommunity === 'community' && $options['version'] == 'default') {
52+
$options['version'] = $latestPhpVersion;
53+
}
54+
$file = "{$options['osvariant']}-{$options['usage']}-{$defaultOrCommunity}";
55+
break;
56+
case 'osx':
57+
case 'windows':
58+
$file = "{$options['osvariant']}";
59+
break;
60+
}
61+
62+
if ($source) {
63+
$file = "{$options['os']}-source";
64+
}
65+
66+
$version = $options['version'];
67+
$versionNoDot = str_replace('.', '', $version);
68+
69+
if (file_exists(__DIR__ . "/include/download-instructions/{$file}.php")) {
70+
include __DIR__ . "/include/download-instructions/{$file}.php";
71+
if ($source) {
72+
return false;
73+
}
74+
return true;
75+
} else {
76+
?>
77+
<p>
78+
There are no instructions yet. Try using the <a href="https://www.php.net/manual/en/install.php">generic installation from source</a>.
79+
</p>
80+
<?php
81+
return false;
82+
}
83+
?>

downloads.php

Lines changed: 162 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
// Try to make this page non-cached
88
header_nocache();
99

10-
$SHOW_COUNT = 4;
11-
1210
$SIDEBAR_DATA = '
1311
<div class="panel">
1412
<a href="/supported-versions.php">Supported Versions</a>
@@ -18,6 +16,7 @@
1816
</div>
1917
</div>
2018
19+
<p class="panel"><a href="downloads.php?source=Y">Source Tarballs</a></p>
2120
<p class="panel"><a href="download-docs.php">Documentation Download</a></p>
2221
<p class="panel"><a href="download-logos.php">PHP Logos</a></p>
2322
@@ -37,14 +36,164 @@
3736
],
3837
],
3938
"current" => "downloads",
39+
"css" => [
40+
"prism.css",
41+
"code-syntax.css",
42+
],
43+
"js_files" => [
44+
"js/ext/prism.js",
45+
],
4046
],
4147
);
48+
49+
function option(string $value, string $desc, $attributes = []): string
50+
{
51+
return '<option value="' . $value . '"' . implode(' ', array_keys(array_filter($attributes))) . '>' . $desc . '</option>';
52+
}
53+
54+
$usage = [
55+
'web' => 'Web Development',
56+
'cli' => 'CLI/Library Development',
57+
'fw-drupal' => 'Drupal Development',
58+
'fw-laravel' => 'Laravel Development',
59+
'fw-symfony' => 'Symfony Development',
60+
'fw-wordpress' => 'WordPress Development',
61+
];
62+
63+
$os = [
64+
'linux' => [
65+
'name' => 'Linux',
66+
'variants' => [
67+
'linux-debian' => 'Debian',
68+
'linux-fedora' => 'Fedora',
69+
'linux-redhat' => 'RedHat',
70+
'linux-ubuntu' => 'Ubuntu',
71+
],
72+
],
73+
'osx' => [
74+
'name' => 'macOS',
75+
'variants' => [
76+
'osx-homebrew' => 'Homebrew/Brew',
77+
'osx-homebrew-php' => 'Homebrew/Homebrew-PHP',
78+
'osx-macports' => 'MacPorts',
79+
],
80+
],
81+
'windows' => [
82+
'name' => 'Windows',
83+
'variants' => [
84+
'windows-native' => 'Windows Native Build',
85+
'windows-chocolatey' => 'Windows with Chocolatey',
86+
'windows-scoop' => 'Windows with Scoop',
87+
'windows-wsl-debian' => 'Windows with WSL/Debian',
88+
'windows-wsl-ubuntu' => 'Windows with WSL/Ubuntu',
89+
],
90+
],
91+
];
92+
93+
$versions = [
94+
'8.4' => 'version 8.4',
95+
'8.3' => 'version 8.3',
96+
'8.2' => 'version 8.2',
97+
'8.1' => 'version 8.1',
98+
'default' => 'OS default version',
99+
];
100+
101+
$defaults = [
102+
'os' => 'linux',
103+
'version' => 'default',
104+
'usage' => 'web',
105+
];
106+
107+
$options = array_merge($defaults, $_GET);
108+
if (!array_key_exists('osvariant', $options) || !array_key_exists($options['osvariant'], $os[$options['os']]['variants'])) {
109+
$options['osvariant'] = array_key_first($os[$options['os']]['variants']);
110+
}
42111
?>
43112
<h1>Downloads &amp; Installation Instructions</h1>
44113

114+
<form class="instructions-form" id="instructions-form">
115+
<div class="instructions-row">
116+
I want to use PHP for
117+
<select id="usage" name="usage">
118+
<?php foreach ($usage as $value => $description) { ?>
119+
<?= option($value, $description, [
120+
'selected' => array_key_exists('usage', $options) && $options['usage'] === $value,
121+
]); ?>
122+
<?php } ?>
123+
</select>.
124+
</div>
125+
126+
<div class="instructions-row">
127+
I work with
128+
<select id="os" name="os">
129+
<?php foreach ($os as $value => $item) { ?>
130+
<?= option($value, $item['name'], [
131+
'selected' => array_key_exists('os', $options) && $options['os'] === $value,
132+
]); ?>
133+
<?php } ?>
134+
</select>
135+
136+
<?php if (array_key_exists('os', $options) && array_key_exists('osvariant', $options)) { ?>
137+
<select id="osvariant" name="osvariant">
138+
<?php foreach ($os[$options['os']]['variants'] as $value => $description) { ?>
139+
<?= option($value, $description, [
140+
'selected' => $options['osvariant'] === $value,
141+
]); ?>
142+
<?php } ?>
143+
</select>
144+
<?php } ?>,
145+
and use
146+
<select id="version" name="version">
147+
<?php foreach ($versions as $value => $version) { ?>
148+
<?= option($value, $version, [
149+
'selected' => array_key_exists('version', $options) && $options['version'] === $value,
150+
]); ?>
151+
<?php } ?>
152+
</select>
153+
</div>
154+
155+
<label for="multiversion" class="instructions-label">
156+
I want to be able to use multiple PHP versions:
157+
<input type="checkbox" id="multiversion" name="multiversion" value="Y"
158+
<?= array_key_exists('multiversion', $options) && $options['multiversion'] === 'Y' ? 'checked' : '' ?>/>
159+
</label>
160+
161+
<label for="source" class="instructions-label">
162+
I want to compile everything from source:
163+
<input type="checkbox" id="source" name="source" value="Y"
164+
<?= array_key_exists('source', $options) && $options['source'] === 'Y' ? 'checked' : '' ?>/>
165+
</label>
166+
167+
<noscript>
168+
<button type="submit" class="button">Update Instructions</button>
169+
</noscript>
170+
</form>
171+
172+
<h2>Instructions</h2>
173+
<div id="instructions" class="instructions">
174+
<?php $instructionsShown = include 'downloads-get-instructions.php'; ?>
175+
</div>
176+
177+
<?php if (!$instructionsShown): ?>
178+
179+
<h2>Source Code</h2>
180+
<?php show_source_releases(); ?>
181+
182+
<hr>
183+
<h2>GPG Keys</h2>
45184
<p>
46-
<a href="/manual/install.general.php">Installing PHP</a> is covered
47-
thoroughly in the PHP documentation.
185+
The releases are tagged and signed in the <a href='git.php'>PHP Git Repository</a>.
186+
The following official GnuPG keys of the current PHP Release Manager can be used
187+
to verify the tags:
188+
</p>
189+
190+
<?php gpg_key_show_keys(true /* activeOnly */); ?>
191+
192+
<p>
193+
<a href="gpg-keys.php">
194+
A full list of GPG keys used for current and older releases is also
195+
available.
196+
</a>
48197
</p>
49198

50199
<h2>Binaries</h2>
@@ -65,67 +214,17 @@
65214
</ul>
66215
</p>
67216

68-
<h2>Source Code</h2>
69-
<?php $i = 0; foreach ($RELEASES as $MAJOR => $major_releases): /* major releases loop start */
70-
$releases = array_slice($major_releases, 0, $SHOW_COUNT);
71-
?>
72-
<a id="v<?php echo $MAJOR; ?>"></a>
73-
<?php foreach ($releases as $v => $a): ?>
74-
<?php $mver = substr($v, 0, strrpos($v, '.')); ?>
75-
<?php $stable = $i++ === 0 ? "Current Stable" : "Old Stable"; ?>
76-
77-
<h3 id="v<?php echo $v; ?>" class="title">
78-
<span class="release-state"><?php echo $stable; ?></span>
79-
PHP <?php echo $v; ?>
80-
(<a href="/ChangeLog-<?php echo $MAJOR; ?>.php#<?php echo urlencode($v); ?>" class="changelog">Changelog</a>)
81-
</h3>
82-
<div class="content-box">
83-
84-
<ul>
85-
<?php foreach ($a['source'] as $rel): ?>
86-
<li>
87-
<?php download_link($rel['filename'], $rel['filename']); ?>
88-
<span class="releasedate"><?php echo date('d M Y', strtotime($rel['date'])); ?></span>
89-
<?php
90-
if (isset($rel['md5'])) echo '<span class="md5sum">', $rel['md5'], '</span>';
91-
if (isset($rel['sha256'])) echo '<span class="sha256">', $rel['sha256'], '</span>';
92-
?>
93-
<?php if (isset($rel['note']) && $rel['note']): ?>
94-
<p>
95-
<strong>Note:</strong>
96-
<?php echo $rel['note']; ?>
97-
</p>
98-
<?php endif; ?>
99-
</li>
100-
<?php endforeach; ?>
101-
<li>
102-
<a href="https://windows.php.net/download#php-<?php echo urlencode($mver); ?>">
103-
Windows downloads
104-
</a>
105-
</li>
106-
</ul>
107-
108-
<a href="#gpg-<?php echo $mver; ?>">GPG Keys for PHP <?php echo $mver; ?></a>
109-
</div>
110-
<?php endforeach; ?>
111-
<?php endforeach; /* major releases loop end */ ?>
112-
113-
<hr>
114-
<h2>GPG Keys</h2>
115-
<p>
116-
The releases are tagged and signed in the <a href='git.php'>PHP Git Repository</a>.
117-
The following official GnuPG keys of the current PHP Release Manager can be used
118-
to verify the tags:
119-
</p>
217+
<?php endif; ?>
120218

121-
<?php gpg_key_show_keys(true /* activeOnly */); ?>
219+
<script>
220+
window.onload = function () {
221+
let form = document.getElementById("instructions-form")
122222

123-
<p>
124-
<a href="gpg-keys.php">
125-
A full list of GPG keys used for current and older releases is also
126-
available.
127-
</a>
128-
</p>
223+
form.addEventListener('change', function () {
224+
form.submit();
225+
});
226+
}
227+
</script>
129228

130229
<?php
131230
site_footer(['sidebar' => $SIDEBAR_DATA]);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<p>
2+
Instructions for installing PHP for Drupal development can be found on:
3+
</p>
4+
<p>
5+
» <a href='https://www.drupal.org/docs/getting-started/installing-drupal'>https://www.drupal.org/docs/getting-started/installing-drupal</a>
6+
</p>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<p>
2+
Instructions for installing PHP for Laravel development can be found on:
3+
</p>
4+
<p>
5+
» <a href='https://laravel.com/docs/12.x/installation#installing-php'>https://laravel.com/docs/12.x/installation#installing-php</a>
6+
</p>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<p>
2+
Instructions for installing PHP for Symfony development can be found on:
3+
</p>
4+
<p>
5+
» <a href='https://symfony.com/doc/current/setup.html'>https://symfony.com/doc/current/setup.html</a>
6+
</p>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<p>
2+
Instructions for installing PHP for WordPress development can be found on:
3+
</p>
4+
<p>
5+
» <a href='https://wordpress.org/support/article/how-to-install-wordpress/'>https://wordpress.org/support/article/how-to-install-wordpress/</a>
6+
</p>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<p>
2+
On the command line, run the following commands:
3+
</p>
4+
<pre><code class="language-bash line-numbers">
5+
# Add the packages.sury.org/php repository.
6+
sudo apt-get update
7+
sudo apt-get install -y lsb-release ca-certificates apt-transport-https curl
8+
sudo curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
9+
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb
10+
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
11+
sudo apt-get update
12+
13+
# Install PHP.
14+
sudo apt-get install -y php<?= $version; ?>
15+
</code></pre>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<p>
2+
On the command line, run the following commands:
3+
</p>
4+
<pre><code class="language-bash line-numbers">
5+
# Update the package lists.
6+
sudo apt update
7+
8+
# Install PHP.
9+
sudo apt install -y php
10+
</code></pre>

0 commit comments

Comments
 (0)