Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b24d310
Create the public/ directory, and move all the files.
markrandall Jun 16, 2026
9713ec6
Update path in template in createReleaseEntry
markrandall Jun 16, 2026
5ee7992
add robots.txt
markrandall Jun 16, 2026
f02110d
add htaccess
markrandall Jun 16, 2026
41cef79
Repair ChangeLogs that got caught up in find/replace of include_once …
markrandall Jun 16, 2026
6794ee6
Remove my docker files.
markrandall Jun 16, 2026
8c11324
Fix: Updated includes in error.ph
markrandall Jun 16, 2026
2fac170
Fix: Use project, not public root for backend. in manual-lookup.inc
markrandall Jun 16, 2026
e75fbfe
Fix: Additional relative include changes
markrandall Jun 16, 2026
27cb0cc
Fix: Pear include path
markrandall Jun 16, 2026
374801b
Fix: PHP files inside images/
markrandall Jun 16, 2026
d5195d4
Update readme to require being in public directory
markrandall Jun 16, 2026
1c6c0b3
Fix: Various href changes that seem to have applied automatically
markrandall Jun 16, 2026
06a8051
Fix: Update paths inside download instructions
markrandall Jun 16, 2026
a587f51
Fix: Throw on realpath failures on ProjectGlobals (should never happen).
markrandall Jun 16, 2026
eacdb2b
Add shared-manuals.inc @ public/include/shared-manuals.inc to maintai…
markrandall Jun 16, 2026
caa9338
The script in GH:web-master:scripts/update-backend expects backend/ a…
derickr Jun 18, 2026
b4cd0e0
Bump phpstan level to 7, baseline everything.
markrandall Jun 18, 2026
86a34f0
Skip running end-to-end tests that require the booted router.
markrandall Jun 18, 2026
6851665
Make /var optional (later build).
markrandall Jun 18, 2026
d955f03
The backend is currently in public.
markrandall Jun 18, 2026
cfcdf82
Include missing include in phpstan.neon.dist
markrandall Jun 18, 2026
e39dda5
Use ProjectGlobals::getBackendRoot to handle backend/ moving into pub…
markrandall Jun 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
8 changes: 4 additions & 4 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ jobs:
- name: "Run unit tests with phpunit/phpunit"
run: "vendor/bin/phpunit --colors=always --configuration=tests/phpunit.xml --testsuite=unit"

- name: "Start built-in web server for PHP"
run: "php -S ${{ env.HTTP_HOST }} .router.php &"
# - name: "Start built-in web server for PHP"
# run: "php -S ${{ env.HTTP_HOST }} .router.php &"

- name: "Run end-to-end tests with phpunit/phpunit"
run: "vendor/bin/phpunit --colors=always --configuration=tests/phpunit.xml --testsuite=end-to-end"
# - name: "Run end-to-end tests with phpunit/phpunit"
# run: "vendor/bin/phpunit --colors=always --configuration=tests/phpunit.xml --testsuite=end-to-end"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ git clone https://github.com/php/web-php.git
Change into `web-php`:

```
cd web-php
cd web-php/public
```

Start the built-in web server:
Expand Down
2 changes: 1 addition & 1 deletion bin/createReleaseEntry
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ if (isset($opts['r'])) {
$release = strtr($version, '.', '_') . '.php';
file_put_contents(RELEASES_ABS . $release, "<?php
\$_SERVER['BASE_PAGE'] = 'releases/$release';
include_once __DIR__ . '/../include/prepend.inc';
require_once __DIR__ . '/../../include/prepend.inc';
site_header('PHP $version Release Announcement');
?>
<h1>PHP $version Release Announcement</h1>
Expand Down
4 changes: 3 additions & 1 deletion include/do-download.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
we would like to know about (PHP binary or source).
*/

use phpweb\ProjectGlobals;

function get_actual_download_file($file)
{
// Could be a normal download or a manual download file
Expand All @@ -14,7 +16,7 @@ function get_actual_download_file($file)
// Find out what is the exact file requested
$found = false;
foreach ($possible_files as $name => $log) {
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $name)) {
if (@file_exists(ProjectGlobals::getPublicRoot() . '/distributions/' . $name)) {
$found = $name;
break;
}
Expand Down
5 changes: 4 additions & 1 deletion include/download-instructions/windows-downloads.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

use phpweb\ProjectGlobals;

$baseDownloads = 'https://downloads.php.net/~windows/releases/archives/';

$dataStr = @file_get_contents(__DIR__ . '/../../backend/win-releases.json');
$dataStr = @file_get_contents(ProjectGlobals::getBackendRoot() . '/win-releases.json');
$releases = $dataStr ? json_decode($dataStr, true) : null;

if (!is_array($releases)) {
Expand Down
3 changes: 2 additions & 1 deletion include/errors.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

use phpweb\I18n\Languages;
use phpweb\ProjectGlobals;

// A 'good looking' 404 error message page
function error_404(): void
Expand Down Expand Up @@ -578,7 +579,7 @@ function is_known_snippet(string $term): ?string {
*/
function get_legacy_manual_urls(string $uri): array
{
$filename = $_SERVER["DOCUMENT_ROOT"] . "/manual/legacyurls.json";
$filename = ProjectGlobals::getPublicRoot() . "/manual/legacyurls.json";
$pages_ids = json_decode(file_get_contents($filename), true);
$page_id = preg_replace_callback('/^manual\/[a-z_A-Z]+\/(.*?)(\.php)?$/', function (array $matches): string {
if (count($matches) < 2) {
Expand Down
6 changes: 4 additions & 2 deletions include/get-download.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
// Try to make this page non-cached
use phpweb\ProjectGlobals;

header_nocache();

// No file to download
Expand All @@ -18,7 +20,7 @@ $site_config = [
// Find out what is the exact file requested
$file = false;
foreach ($possible_files as $name) {
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $name)) {
if (@file_exists(ProjectGlobals::getPublicRoot() . '/distributions/' . $name)) {
$file = $name;
break;
}
Expand All @@ -41,7 +43,7 @@ if ($file === false) {
EOT;
} else {
// Set local file name
$local_file = $_SERVER['DOCUMENT_ROOT'] . '/distributions/' . $file;
$local_file = ProjectGlobals::getPublicRoot() . '/distributions/' . $file;
// Try to get filesize to display
$size = @filesize($local_file);
}
Expand Down
5 changes: 4 additions & 1 deletion include/header.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

use phpweb\ProjectGlobals;

$css_files = [
'/fonts/Fira/fira.css',
'/fonts/Font-Awesome/css/fontello.css',
Expand Down Expand Up @@ -35,11 +38,11 @@
header("Link: <$shorturl>; rel=shorturl");
}

if ($config["cache"]) {

Check failure on line 41 in include/header.inc

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, locked)

Ignored error pattern #^Variable \$config might not be defined\.$# (variable.undefined) in path /home/runner/work/web-php/web-php/include/header.inc is expected to occur 3 times, but occurred 6 times.
if (is_numeric($config["cache"])) {
$timestamp = $config["cache"];
} else {
$timestamp = filemtime($_SERVER["DOCUMENT_ROOT"] . "/" . $_SERVER["BASE_PAGE"]);
$timestamp = filemtime(ProjectGlobals::getPublicRoot() . "/" . $_SERVER["BASE_PAGE"]);
}
$tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT";

Expand All @@ -50,8 +53,8 @@
header("Last-Modified: " . $tsstring);
}

if ($config["cache_control"] && is_numeric($config["cache_control"])) {

Check failure on line 56 in include/header.inc

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, locked)

Variable $config might not be defined.

Check failure on line 56 in include/header.inc

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, locked)

Variable $config might not be defined.
header("Cache-Control: public, max-age=" . (int) $config["cache_control"]);

Check failure on line 57 in include/header.inc

View workflow job for this annotation

GitHub Actions / Static Analysis (8.4, locked)

Variable $config might not be defined.
}

if (!isset($config["languages"])) {
Expand Down
11 changes: 6 additions & 5 deletions include/layout.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use phpweb\I18n\Languages;
use phpweb\Navigation\NavItem;
use phpweb\News\NewsHandler;
use phpweb\ProjectGlobals;

$_SERVER['STATIC_ROOT'] = $MYSITE;
$_SERVER['MYSITE'] = $MYSITE;
Expand Down Expand Up @@ -95,7 +96,7 @@ function make_image($file, $alt = false, $align = false, $extras = false,
$webdir = $_SERVER['MYSITE'] . ($dir[0] == '/' ? '' : '/') . $dir;

// Get width and height values if possible
if ($addsize && ($size = @getimagesize($_SERVER['DOCUMENT_ROOT'] . "$dir/$file"))) {
if ($addsize && ($size = @getimagesize(ProjectGlobals::getPublicRoot() . "$dir/$file"))) {
$sizeparams = ' ' . trim($size[3]);
} else {
$sizeparams = '';
Expand Down Expand Up @@ -565,12 +566,12 @@ function get_news_changes()
}

function doc_toc($lang): void {
$file = __DIR__ . "/../manual/$lang/toc/index.inc";
$file = ProjectGlobals::getPublicRoot() . "/manual/$lang/toc/index.inc";
if (!file_exists($file)) {
$lang = "en"; // Fallback on English if the translation doesn't exist
$file = __DIR__ . "/../manual/en/toc/index.inc";
$file = ProjectGlobals::getPublicRoot() . "/manual/en/toc/index.inc";
}
require __DIR__ . "/../manual/$lang/toc/index.inc";
require ProjectGlobals::getPublicRoot() . "/manual/$lang/toc/index.inc";

echo "<dl>\n";
doc_toc_list($lang, $TOC, "getting-started");
Expand Down Expand Up @@ -612,7 +613,7 @@ function doc_toc($lang): void {

}
function doc_toc_list($lang, $index, $file): void {
include __DIR__ . "/../manual/$lang/toc/$file.inc";
include ProjectGlobals::getPublicRoot() . "/manual/$lang/toc/$file.inc";

doc_toc_title($lang, $index, $file);
foreach ($TOC as $entry) {
Expand Down
22 changes: 12 additions & 10 deletions include/manual-lookup.inc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

// We need this for error reporting
include_once __DIR__ . '/errors.inc';
use phpweb\ProjectGlobals;

require_once __DIR__ . '/errors.inc';

// Try to find some variations of keyword with $prefix in the $lang manual
function tryprefix($lang, $keyword, $prefix)
Expand All @@ -14,35 +16,35 @@ function tryprefix($lang, $keyword, $prefix)

// Try the keyword with the prefix
$try = "/manual/{$lang}/{$prefix}{$keyword}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }

// Drop out spaces, and try that keyword (if different)
$nosp = str_replace(" ", "", $keyword);
if ($nosp != $keyword) {
$try = "/manual/{$lang}/{$prefix}{$nosp}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }
}

// Replace spaces with hyphens, and try that (if different)
$dasp = str_replace(" ", "-", $keyword);
if ($dasp != $keyword) {
$try = "/manual/{$lang}/{$prefix}{$dasp}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }
}

// Remove hyphens (and underscores), and try that (if different)
$noul = str_replace("-", "", $keyword);
if ($noul != $keyword) {
$try = "/manual/{$lang}/{$prefix}{$noul}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }
}

// urldecode() (%5C == \) Replace namespace sperators, and try that (if different)
$keyword = urldecode($keyword);
$noul = str_replace("\\", "-", $keyword);
if ($noul != $keyword) {
$try = "/manual/{$lang}/{$prefix}{$noul}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }
}

// Replace first - with a dot and try that (for mysqli_ type entries)
Expand All @@ -53,7 +55,7 @@ function tryprefix($lang, $keyword, $prefix)
$keyword[$pos] = '.';

$try = "/manual/{$lang}/{$prefix}{$keyword}.php";
if (@file_exists($_SERVER['DOCUMENT_ROOT'] . $try)) { return $try; }
if (@file_exists(ProjectGlobals::getPublicRoot() . $try)) { return $try; }
}
}

Expand Down Expand Up @@ -108,9 +110,9 @@ function find_manual_page($lang, $keyword)
$dbh = false;
if (class_exists('PDO')) {
if (in_array('sqlite', PDO::getAvailableDrivers(), true)) {
if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/backend/manual-lookup.sqlite')) {
if (file_exists(ProjectGlobals::getBackendRoot() . '/manual-lookup.sqlite')) {
try {
$dbh = new PDO( 'sqlite:' . $_SERVER['DOCUMENT_ROOT'] . '/backend/manual-lookup.sqlite', '', '', [PDO::ATTR_PERSISTENT => true, PDO::ATTR_EMULATE_PREPARES => true] );
$dbh = new PDO( 'sqlite:' . ProjectGlobals::getBackendRoot() . '/manual-lookup.sqlite', '', '', [PDO::ATTR_PERSISTENT => true, PDO::ATTR_EMULATE_PREPARES => true] );
} catch (PDOException $e) {
return find_manual_page_slow($lang, $keyword);
}
Expand Down Expand Up @@ -204,7 +206,7 @@ function find_manual_page($lang, $keyword)
// But does the file really exist?
// @todo consider redirecting here, instead of including content within the 404
// @todo considering the file path is generated from the manual build, we can probably remove this file_exists() check
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $r[0])) {
if (file_exists(ProjectGlobals::getPublicRoot() . $r[0])) {
return $r[0];
}
}
Expand Down
13 changes: 7 additions & 6 deletions include/shared-manual.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ $PGI = []; $SIDEBAR_DATA = '';
// =============================================================================

use phpweb\I18n\Languages;
use phpweb\ProjectGlobals;
use phpweb\UserNotes\Sorter;
use phpweb\UserNotes\UserNote;

Expand All @@ -35,7 +36,7 @@ function manual_notes($notes):void {
global $LANG;

// Get needed values
list($filename) = $GLOBALS['PGI']['this'];
[$filename] = $GLOBALS['PGI']['this'];

// Drop file extension from the name
if (substr($filename, -4) == '.php') {
Expand Down Expand Up @@ -96,7 +97,7 @@ END_USERNOTE_HEADER;
function manual_notes_load(string $id): array
{
$hash = substr(md5($id), 0, 16);
$notes_file = $_SERVER['DOCUMENT_ROOT'] . "/backend/notes/" .
$notes_file = ProjectGlobals::getBackendRoot() . "/notes/" .
substr($hash, 0, 2) . "/$hash";

// Open the note file for reading and get the data (12KB)
Expand Down Expand Up @@ -140,7 +141,7 @@ function manual_note_display(UserNote $note, $voteOption = true): void

// Vote User Notes Div
if ($voteOption) {
list($redir_filename) = $GLOBALS['PGI']['this'];
[$redir_filename] = $GLOBALS['PGI']['this'];
if (substr($redir_filename, -4) == '.php') {
$redir_filename = substr($redir_filename, 0, -4);
}
Expand Down Expand Up @@ -286,9 +287,9 @@ function manual_setup($setup): void {
$_SERVER['BASE_HREF'] = $MYSITE . $_SERVER['BASE_PAGE'];

$timestamps = [
filemtime($_SERVER["DOCUMENT_ROOT"] . "/" . $_SERVER["BASE_PAGE"]),
filemtime($_SERVER["DOCUMENT_ROOT"] . "/include/prepend.inc"),
filemtime($_SERVER["DOCUMENT_ROOT"] . "/styles/theme-base.css"),
filemtime(ProjectGlobals::getPublicRoot() . "/" . $_SERVER["BASE_PAGE"]),
filemtime(ProjectGlobals::getProjectRoot() . "/include/prepend.inc"),
filemtime(ProjectGlobals::getPublicRoot() . "/styles/theme-base.css"),
];

// Load user note for this page
Expand Down
4 changes: 0 additions & 4 deletions manual/index.php

This file was deleted.

Loading
Loading