-
Notifications
You must be signed in to change notification settings - Fork 563
First stab at a prototype for revamping the download instructions page #1277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
if ($_GET['os'] === 'windows' && $_GET['osvariant'] === 'windows-wsl') { | ||
$_GET['os'] = 'linux'; | ||
$_GET['osvariant'] = 'linux-deb-bookworm'; | ||
$_GET['multiversion'] = 'true'; | ||
} | ||
if ($_GET['os'] === 'osx') { | ||
$version = match($_GET['version']) { | ||
'php84' => '@8.4', | ||
'php83' => '@8.3', | ||
'php82' => '@8.2', | ||
'php81' => '@8.1', | ||
default => '' | ||
}; | ||
|
||
$versionDir = match($_GET['version']) { | ||
'php84' => '8.4', | ||
'php83' => '8.3', | ||
'php82' => '8.2', | ||
'php81' => '8.1', | ||
default => '8.4' | ||
}; | ||
|
||
echo <<<ENDOSX | ||
<p> | ||
On the OSX command line shell, enter: | ||
</p> | ||
<div class="example"><div class="example-contents screen"><pre> | ||
brew install php{$version} | ||
</pre></div></div> | ||
<p> | ||
To enable PHP in Apache add the following to httpd.conf and restart Apache: | ||
</p> | ||
<div class="example"><div class="example-contents screen"><pre> | ||
LoadModule php_module \$HOMEBREW_PREFIX/opt/php/lib/httpd/modules/libphp.so | ||
|
||
<FilesMatch \.php$> | ||
SetHandler application/x-httpd-php | ||
</FilesMatch> | ||
</pre></div></div> | ||
<p> | ||
Finally, check DirectoryIndex includes index.php | ||
</p> | ||
<div class="example"><div class="example-contents screen"><pre> | ||
DirectoryIndex index.php index.html | ||
</pre></div></div> | ||
<p> | ||
The php.ini and php-fpm.ini file can be found in: | ||
</p> | ||
<div class="example"><div class="example-contents screen"><pre> | ||
\$HOMEBREW_PREFIX/etc/php/{$versionDir}/ | ||
</pre></div></div> | ||
</p> | ||
ENDOSX; | ||
return; | ||
} | ||
?> | ||
<?php | ||
if ($_GET['os'] === 'linux' && str_starts_with($_GET['osvariant'], 'linux-deb')) { | ||
if ($_GET['version'] === 'default' && $_GET['multiversion'] != 'true') { | ||
echo <<<ENDAPT | ||
<p> | ||
On the command line shell, enter: | ||
</p> | ||
<div class="example"><div class="example-contents screen"><pre> | ||
sudo apt-get update | ||
sudo apt-get install php | ||
</pre></div></div> | ||
ENDAPT; | ||
} else { | ||
$version = match($_GET['version']) { | ||
'php84' => '8.4', | ||
'php83' => '8.3', | ||
'php82' => '8.2', | ||
'php81' => '8.1', | ||
default => '8.4' | ||
}; | ||
echo <<<ENDAPT | ||
<p> | ||
On the command line shell, enter: | ||
</p> | ||
<div class="example"><div class="example-contents screen"><pre> | ||
sudo apt -y install software-properties-common | ||
sudo add-apt-repository ppa:ondrej/php | ||
sudo apt update | ||
sudo apt install php{$version} | ||
</pre></div></div> | ||
Comment on lines
+82
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using PPAs is Ubuntu-specific. For Debian the repository should be set up as per: https://packages.sury.org/php/README.txt There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we need to work on all of these. And probably also stick them in files. |
||
ENDAPT; | ||
} | ||
return; | ||
} | ||
?> | ||
<p> | ||
There are no instructions yet. | ||
</p> | ||
|
||
<?php var_dump($_GET); ?> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ | |
// Try to make this page non-cached | ||
header_nocache(); | ||
|
||
$SHOW_COUNT = 4; | ||
|
||
$SIDEBAR_DATA = ' | ||
<div class="panel"> | ||
<a href="/supported-versions.php">Supported Versions</a> | ||
|
@@ -37,15 +35,85 @@ | |
], | ||
], | ||
"current" => "downloads", | ||
"js_files" => [ | ||
"/js/version-choice.js", | ||
], | ||
], | ||
); | ||
|
||
function option(string $id, string $value, string $desc) | ||
{ | ||
$selected = ''; | ||
if (array_key_exists($id, $_GET) && $_GET[$id] === $value) { | ||
$selected = ' selected'; | ||
} | ||
|
||
echo <<<ENDOPT | ||
<option value="{$value}"{$selected}>{$desc}</option> | ||
|
||
ENDOPT; | ||
} | ||
?> | ||
<h1>Downloads & Installation Instructions</h1> | ||
|
||
<form> | ||
Get PHP for | ||
<select id="os" name="os"> | ||
<?= option('os', 'linux', 'Linux'); ?> | ||
<?= option('os', 'osx', 'OSX'); ?> | ||
<?= option('os', 'windows', 'Windows'); ?> | ||
</select> | ||
|
||
<select id="osvariant" name="osvariant"> | ||
<?= option('osvariant', 'linux-deb-buster', 'Debian Buster'); ?> | ||
<?= option('osvariant', 'linux-deb-bullseye', 'Debian Bullseye'); ?> | ||
<?= option('osvariant', 'linux-deb-bookworm', 'Debian Bookworm'); ?> | ||
<?= option('osvariant', 'linux-rpm-fedora41', 'Fedora 41'); ?> | ||
<?= option('osvariant', 'linux-rpm-fedora42', 'Fedora 42'); ?> | ||
<?= option('osvariant', 'linux-rpm-redhat', 'RedHat'); ?> | ||
<?= option('osvariant', 'osx-latest', 'Latest'); ?> | ||
<?= option('osvariant', 'windows-wsl', 'with WSL'); ?> | ||
<?= option('osvariant', 'windows-normal', 'without WSL'); ?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The prefixes are important here for disabling/enabling based on OS. |
||
</select> | ||
|
||
to work on | ||
<select id="usage" name="usage"> | ||
<?= option('usage', 'web', 'Web Development'); ?> | ||
<?= option('usage', 'cli', 'Command Line Libraries'); ?> | ||
<?= option('usage', 'fw-drupal', 'Drupal'); ?> | ||
<?= option('usage', 'fw-laravel', 'Laravel'); ?> | ||
<?= option('usage', 'fw-symfony', 'Symfony'); ?> | ||
</select> | ||
|
||
with | ||
<select id="version" name="version"> | ||
<?= option('version', 'php84', 'version 8.4'); ?> | ||
<?= option('version', 'php83', 'version 8.3'); ?> | ||
<?= option('version', 'php82', 'version 8.2'); ?> | ||
<?= option('version', 'php81', 'version 8.1'); ?> | ||
<?= option('version', 'default', 'OS default version'); ?> | ||
</select> | ||
|
||
<input type='submit' value="Go!"></input> | ||
|
||
<br/> | ||
|
||
I want to have multiple versions at the same time: | ||
<input type="checkbox" id="multiversion" name="multiversion" label="I want to have multiple versions at the same time"> | ||
</input> | ||
</form> | ||
|
||
<h2>Instructions</h2> | ||
<div id="instructions"> | ||
<?php include 'downloads-get-instructions.php'; ?> | ||
</div> | ||
|
||
<!-- | ||
<p> | ||
<a href="/manual/install.general.php">Installing PHP</a> is covered | ||
thoroughly in the PHP documentation. | ||
</p> | ||
--> | ||
|
||
<h2>Binaries</h2> | ||
|
||
|
@@ -66,49 +134,7 @@ | |
</p> | ||
|
||
<h2>Source Code</h2> | ||
<?php $i = 0; foreach ($RELEASES as $MAJOR => $major_releases): /* major releases loop start */ | ||
$releases = array_slice($major_releases, 0, $SHOW_COUNT); | ||
?> | ||
<a id="v<?php echo $MAJOR; ?>"></a> | ||
<?php foreach ($releases as $v => $a): ?> | ||
<?php $mver = substr($v, 0, strrpos($v, '.')); ?> | ||
<?php $stable = $i++ === 0 ? "Current Stable" : "Old Stable"; ?> | ||
|
||
<h3 id="v<?php echo $v; ?>" class="title"> | ||
<span class="release-state"><?php echo $stable; ?></span> | ||
PHP <?php echo $v; ?> | ||
(<a href="/ChangeLog-<?php echo $MAJOR; ?>.php#<?php echo urlencode($v); ?>" class="changelog">Changelog</a>) | ||
</h3> | ||
<div class="content-box"> | ||
|
||
<ul> | ||
<?php foreach ($a['source'] as $rel): ?> | ||
<li> | ||
<?php download_link($rel['filename'], $rel['filename']); ?> | ||
<span class="releasedate"><?php echo date('d M Y', strtotime($rel['date'])); ?></span> | ||
<?php | ||
if (isset($rel['md5'])) echo '<span class="md5sum">', $rel['md5'], '</span>'; | ||
if (isset($rel['sha256'])) echo '<span class="sha256">', $rel['sha256'], '</span>'; | ||
?> | ||
<?php if (isset($rel['note']) && $rel['note']): ?> | ||
<p> | ||
<strong>Note:</strong> | ||
<?php echo $rel['note']; ?> | ||
</p> | ||
<?php endif; ?> | ||
</li> | ||
<?php endforeach; ?> | ||
<li> | ||
<a href="https://windows.php.net/download#php-<?php echo urlencode($mver); ?>"> | ||
Windows downloads | ||
</a> | ||
</li> | ||
</ul> | ||
|
||
<a href="#gpg-<?php echo $mver; ?>">GPG Keys for PHP <?php echo $mver; ?></a> | ||
</div> | ||
<?php endforeach; ?> | ||
<?php endforeach; /* major releases loop end */ ?> | ||
<?php show_source_releases(); ?> | ||
|
||
<hr> | ||
<h2>GPG Keys</h2> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
function setSelectBoxes() { | ||
let instructionsDiv = document.getElementById("instructions") | ||
let osSelector = document.getElementById("os") | ||
let variantSelector = document.getElementById("osvariant") | ||
let usageSelector = document.getElementById("usage") | ||
let versionSelector = document.getElementById("version") | ||
let multiversionBox = document.getElementById("multiversion") | ||
|
||
const url = '/downloads-get-instructions.php' + | ||
'?os=' + osSelector.options[osSelector.selectedIndex].value + | ||
'&osvariant=' + variantSelector.options[variantSelector.selectedIndex].value + | ||
'&usage=' + usageSelector.options[usageSelector.selectedIndex].value + | ||
'&version=' + versionSelector.options[versionSelector.selectedIndex].value + | ||
'&multiversion=' + multiversionBox.checked | ||
|
||
fetch(url) | ||
.then(response => { | ||
if (response.ok) { | ||
return response.text() | ||
} else { | ||
throw new Error("Couldn't fetch instructions"); | ||
} | ||
}) | ||
.then(data => { | ||
instructionsDiv.innerHTML = data | ||
}) | ||
.catch(error => console.error("Couldn't fetch instructions: ", error)); | ||
} | ||
|
||
function setSelectOsBoxes() { | ||
let osSelector = document.getElementById("os") | ||
let variantSelector = document.getElementById("osvariant") | ||
|
||
for (var i = variantSelector.length - 1; i >= 0; i--) { | ||
if (!variantSelector.options[i].value.startsWith(osSelector.options[osSelector.selectedIndex].value + "-")) { | ||
variantSelector.options[i].disabled = true | ||
} else { | ||
variantSelector.options[i].disabled = false | ||
variantSelector.selectedIndex = i | ||
} | ||
} | ||
|
||
setSelectBoxes(); | ||
} | ||
|
||
window.onload = function() { | ||
let osSelector = document.getElementById("os") | ||
let variantSelector = document.getElementById("osvariant") | ||
let usageSelector = document.getElementById("usage") | ||
let versionSelector = document.getElementById("version") | ||
let multiversionBox = document.getElementById("multiversion") | ||
|
||
osSelector.addEventListener("change", setSelectOsBoxes) | ||
variantSelector.addEventListener("change", setSelectBoxes) | ||
usageSelector.addEventListener("change", setSelectBoxes) | ||
versionSelector.addEventListener("change", setSelectBoxes) | ||
multiversionBox.addEventListener("change", setSelectBoxes) | ||
|
||
setSelectOsBoxes() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "routing" needs to be more clever, likely.