Skip to content

Commit be6f0cc

Browse files
committed
Add a script to pull down the dynamically generated files directly from php.net
1 parent 8eaa6f0 commit be6f0cc

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

bin/sync-pregen.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
if (php_sapi_name() !== 'cli') {
4+
die('This script must be run from the command line.');
5+
}
6+
7+
$required_files = [
8+
'include/pregen-events.inc',
9+
'include/pregen-news.inc',
10+
'include/pregen-confs.inc',
11+
'feed.atom',
12+
'news.rss',
13+
'conferences/news.rss',
14+
'backend/win-releases.json',
15+
'backend/win-qa-releases.json',
16+
];
17+
18+
fwrite(STDOUT, "Copying data from production server into local directories:\n");
19+
fwrite(STDOUT, "Do not commit these files!\n");
20+
21+
foreach ($required_files as $fileName) {
22+
$url = 'https://www.php.net/' . $fileName;
23+
$source = @file_get_contents($url);
24+
if ($source === false) {
25+
fwrite(STDERR, "Unable to read " . $url . "\n");
26+
exit(1);
27+
}
28+
29+
$saveTo = __DIR__ . '/../' . $fileName;
30+
$success = file_put_contents($saveTo, $source);
31+
if ($success === false) {
32+
fwrite(STDERR, "Unable to write to " . $saveTo . "\n");
33+
exit(1);
34+
}
35+
36+
fwrite(STDOUT, "Copied " . $url . " to " . $saveTo . "\n");
37+
}

0 commit comments

Comments
 (0)