Skip to content

Commit c13c88f

Browse files
committed
Re-do logic according to Shivam's instructions, and add instructions to repo
1 parent 974d155 commit c13c88f

24 files changed

+210
-117
lines changed

downloads-get-instructions.php

Lines changed: 48 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,60 @@
11
<?php
2-
if ($options['os'] === 'windows' && $options['osvariant'] === 'windows-wsl') {
3-
$options['os'] = 'linux';
4-
$options['osvariant'] = 'linux-deb-bookworm';
5-
$options['multiversion'] = 'true';
2+
$file = 'unknown';
3+
$latestPhpVersion = '8.4';
4+
5+
if ($options['os'] === 'windows') {
6+
if ($options['osvariant'] === 'windows-wsl-debian') {
7+
$options['os'] = 'linux';
8+
$options['osvariant'] = 'linux-debian';
9+
}
10+
if ($options['osvariant'] === 'windows-wsl-ubuntu') {
11+
$options['os'] = 'linux';
12+
$options['osvariant'] = 'linux-ubuntu';
13+
}
614
}
715
if ($options['os'] === 'osx') {
8-
$version = match($options['version']) {
9-
'php84' => '@8.4',
10-
'php83' => '@8.3',
11-
'php82' => '@8.2',
12-
'php81' => '@8.1',
13-
default => ''
14-
};
16+
if ($options['version'] === 'default') {
17+
$options['version'] = $latestPhpVersion;
18+
}
19+
}
1520

16-
$versionDir = match($options['version']) {
17-
'php84' => '8.4',
18-
'php83' => '8.3',
19-
'php82' => '8.2',
20-
'php81' => '8.1',
21-
default => '8.4'
22-
};
21+
if (in_array($options['usage'], ['fw-drupal', 'fw-laravel', 'fw-symfony', 'fw-wordpress'])) {
22+
$file = "{$options['usage']}";
23+
$options['os'] = null;
24+
}
2325

24-
echo <<<ENDOSX
25-
<p>
26-
On the OSX command line shell, enter:
27-
</p>
28-
<div class="phpcode"><pre>
29-
brew install php{$version}
30-
</pre></div>
31-
<p>
32-
To enable PHP in Apache add the following to httpd.conf and restart Apache:
33-
</p>
34-
<div class="phpcode"><pre>
35-
LoadModule php_module \$HOMEBREW_PREFIX/opt/php/lib/httpd/modules/libphp.so
26+
$multiversion = false;
3627

37-
&lt;FilesMatch \.php$>
38-
SetHandler application/x-httpd-php
39-
&lt;/FilesMatch>
40-
</pre></div>
41-
<p>
42-
Finally, check DirectoryIndex includes index.php
43-
</p>
44-
<div class="phpcode"><pre>
45-
DirectoryIndex index.php index.html
46-
</pre></div>
47-
<p>
48-
The php.ini and php-fpm.ini file can be found in:
49-
</p>
50-
<div class="phpcode"><pre>
51-
\$HOMEBREW_PREFIX/etc/php/{$versionDir}/
52-
</pre></div>
53-
</p>
54-
ENDOSX;
55-
return;
28+
if (array_key_exists('multiversion', $options)) {
29+
$multiversion = $options['multiversion'] === 'Y';
5630
}
31+
32+
switch ($options['os']) {
33+
case 'linux':
34+
$defaultOrCommunity = ($options['version'] !== 'default' || $multiversion) ? 'community' : 'default';
35+
if ($defaultOrCommunity === 'community' && $options['version'] == 'default') {
36+
$options['version'] = $latestPhpVersion;
37+
}
38+
$file = "{$options['osvariant']}-{$options['usage']}-{$defaultOrCommunity}";
39+
break;
40+
case 'osx':
41+
case 'windows':
42+
$file = "{$options['osvariant']}";
43+
break;
44+
}
45+
46+
$version = $options['version'];
47+
$versionNoDot = str_replace('.', '', $version);
48+
49+
if (file_exists(__DIR__ . "/include/download-instructions/{$file}.php")) {
50+
include __DIR__ . "/include/download-instructions/{$file}.php";
51+
return true;
52+
} else {
5753
?>
58-
<?php
59-
if ($options['os'] === 'linux' && str_starts_with($options['osvariant'], 'linux-deb')) {
60-
if ($options['version'] === 'default' && $options['multiversion'] != 'true') {
61-
echo <<<ENDAPT
6254
<p>
63-
On the command line shell, enter:
55+
There are no instructions yet. Try using the generic installation from source.
6456
</p>
65-
<div class="phpcode"><pre>
66-
sudo apt-get update
67-
sudo apt-get install php
68-
</pre></div>
69-
ENDAPT;
70-
} else {
71-
$version = match($options['version']) {
72-
'php84' => '8.4',
73-
'php83' => '8.3',
74-
'php82' => '8.2',
75-
'php81' => '8.1',
76-
default => '8.4'
77-
};
78-
echo <<<ENDAPT
79-
<p>
80-
On the command line shell, enter:
81-
</p>
82-
<div class="phpcode"><pre>
83-
sudo apt -y install software-properties-common
84-
sudo add-apt-repository ppa:ondrej/php
85-
sudo apt update
86-
sudo apt install php{$version}
87-
</pre></div>
88-
ENDAPT;
89-
}
90-
return;
57+
<?php
58+
return false;
9159
}
9260
?>
93-
<p>
94-
There are no instructions yet.
95-
</p>
96-
97-
<?php var_dump($options); ?>

downloads.php

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -56,40 +56,43 @@ function option(string $value, string $desc, $attributes = []): string
5656
'linux' => [
5757
'name' => 'Linux',
5858
'variants' => [
59-
'linux-deb-buster' => 'Debian Buster',
60-
'linux-deb-bullseye' => 'Debian Bullseye',
61-
'linux-deb-bookworm' => 'Debian Bookworm',
62-
'linux-rpm-fedora41' => 'Fedora 41',
63-
'linux-rpm-fedora42' => 'Fedora 42',
64-
'linux-rpm-redhat' => 'RedHat',
59+
'linux-debian' => 'Debian',
60+
'linux-fedora' => 'Fedora',
61+
'linux-redhat' => 'RedHat',
62+
'linux-ubuntu' => 'Ubuntu',
6563
],
6664
],
6765
'osx' => [
6866
'name' => 'macOS',
6967
'variants' => [
70-
'osx-latest' => 'macOS Latest',
68+
'osx-homebrew' => 'Homebrew/Brew',
69+
'osx-homebrew-php' => 'Homebrew/Homebrew-PHP',
70+
'osx-macports' => 'MacPorts',
7171
],
7272
],
7373
'windows' => [
7474
'name' => 'Windows',
7575
'variants' => [
76-
'windows-wsl' => 'Windows with WSL',
77-
'windows-normal' => 'Windows without WSL',
76+
'windows-native' => 'Windows Native Build',
77+
'windows-chocolatey' => 'Windows with Chocolatey',
78+
'windows-scoop' => 'Windows with Scoop',
79+
'windows-wsl-debian' => 'Windows with WSL/Debian',
80+
'windows-wsl-ubuntu' => 'Windows with WSL/Ubuntu',
7881
],
7982
],
8083
];
8184

8285
$versions = [
83-
'php84' => 'version 8.4',
84-
'php83' => 'version 8.3',
85-
'php82' => 'version 8.2',
86-
'php81' => 'version 8.1',
86+
'8.4' => 'version 8.4',
87+
'8.3' => 'version 8.3',
88+
'8.2' => 'version 8.2',
89+
'8.1' => 'version 8.1',
8790
'default' => 'OS default version',
8891
];
8992

9093
$defaults = [
9194
'os' => 'linux',
92-
'version' => 'php84',
95+
'version' => 'default',
9396
'usage' => 'web',
9497
];
9598

@@ -160,26 +163,10 @@ function option(string $value, string $desc, $attributes = []): string
160163

161164
<h2>Instructions</h2>
162165
<div id="instructions" class="instructions">
163-
<?php include 'downloads-get-instructions.php'; ?>
166+
<?php $instructionsShown = include 'downloads-get-instructions.php'; ?>
164167
</div>
165168

166-
<h2>Binaries</h2>
167-
168-
<p>
169-
<a href="https://windows.php.net/download/">Binaries are available for
170-
Microsoft Windows</a>. The PHP project does not currently release binary packages
171-
for other platforms such as Linux or macOS, but they are packaged by distributions
172-
and other providers. For more information, see:
173-
174-
<ul>
175-
<li>
176-
<a href="/manual/install.unix.php">Installation instructions for Unix systems</a>
177-
</li>
178-
<li>
179-
<a href="/manual/install.macosx.php">Installation instructions for macOS</a>
180-
</li>
181-
</ul>
182-
</p>
169+
<?php if (!$instructionsShown): ?>
183170

184171
<h2>Source Code</h2>
185172
<?php show_source_releases(); ?>
@@ -201,6 +188,26 @@ function option(string $value, string $desc, $attributes = []): string
201188
</a>
202189
</p>
203190

191+
<h2>Binaries</h2>
192+
193+
<p>
194+
<a href="https://windows.php.net/download/">Binaries are available for
195+
Microsoft Windows</a>. The PHP project does not currently release binary packages
196+
for other platforms such as Linux or macOS, but they are packaged by distributions
197+
and other providers. For more information, see:
198+
199+
<ul>
200+
<li>
201+
<a href="/manual/install.unix.php">Installation instructions for Unix systems</a>
202+
</li>
203+
<li>
204+
<a href="/manual/install.macosx.php">Installation instructions for macOS</a>
205+
</li>
206+
</ul>
207+
</p>
208+
209+
<?php endif; ?>
210+
204211
<script>
205212
window.onload = function () {
206213
let form = document.getElementById("instructions-form")
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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<p>
2+
On the command line, run the following commands:
3+
</p>
4+
<pre class="shellCommands">
5+
sudo apt-get update
6+
sudo apt-get install -y lsb-release ca-certificates apt-transport-https curl
7+
sudo curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
8+
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb
9+
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/debsuryorg-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" &gt; /etc/apt/sources.list.d/php.list'
10+
sudo apt-get update
11+
sudo apt-get install -y php<?= $version; ?>
12+
</pre>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p>
2+
On the command line, run the following commands:
3+
</p>
4+
<pre class="shellCommands">
5+
sudo apt update
6+
sudo apt install -y php
7+
</pre>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
linux-debian-cli-community.php
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
linux-debian-cli-default.php

0 commit comments

Comments
 (0)