Skip to content

Commit 194b528

Browse files
committed
Add and fix Windows functionality
1 parent 63a7139 commit 194b528

20 files changed

Lines changed: 546 additions & 37 deletions

.github/CONTRIBUTING.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,32 @@ $ tests/vendor/bin/phpunit -c phpunit.xml.dist
5050

5151
The CLI test dependencies install into `tests/vendor/`, leaving the main application `vendor/` directory unchanged.
5252

53+
On Windows PowerShell, set the Composer config and run the same suite with:
54+
55+
```powershell
56+
Set-Location tests
57+
$env:COMPOSER = 'composer.cli-tests.json'
58+
composer install
59+
Set-Location ..
60+
php tests/vendor/bin/phpunit -c phpunit.xml.dist
61+
```
62+
63+
Sandbox CLI or web UI changes must remain compatible with macOS, Linux, and native Windows. Before submitting such changes, run:
64+
65+
```bash
66+
php bin/qi doctor
67+
php bin/qi help
68+
```
69+
70+
On Windows, also smoke-test both supplied launchers:
71+
72+
```powershell
73+
.\bin\qi.ps1 help
74+
.\bin\qi.cmd help
75+
```
76+
77+
Windows-specific changes should cover drive-letter paths, paths containing spaces, Command Prompt and PowerShell execution, and the `ui:start`/`ui:status`/`ui:stop` lifecycle. GitHub Actions runs the PHPUnit suite and launcher smoke tests on native Windows.
78+
5379
## :computer: Make something great
5480

5581
1. Create a new branch in your repository before doing any work. It should be based off the `develop` branch:

.github/workflows/cli-tests.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,40 @@ jobs:
3737

3838
- name: Lint CLI entrypoint
3939
run: php -l bin/qi
40+
41+
windows:
42+
name: Windows PHP 8.3
43+
runs-on: windows-latest
44+
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v6
48+
49+
- name: Setup PHP
50+
uses: shivammathur/setup-php@v2
51+
with:
52+
php-version: '8.3'
53+
coverage: none
54+
55+
- name: Validate test Composer config
56+
working-directory: tests
57+
env:
58+
COMPOSER: composer.cli-tests.json
59+
run: composer validate --no-check-publish --strict
60+
61+
- name: Install test dependencies
62+
working-directory: tests
63+
env:
64+
COMPOSER: composer.cli-tests.json
65+
run: composer install --no-interaction --prefer-dist
66+
67+
- name: Run PHPUnit
68+
run: php tests/vendor/bin/phpunit -c phpunit.xml.dist
69+
70+
- name: Smoke test CMD launcher
71+
shell: cmd
72+
run: bin\qi.cmd help
73+
74+
- name: Smoke test PowerShell launcher
75+
shell: pwsh
76+
run: .\bin\qi.ps1 help

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ QuickInstall is a tool we built to support the community of phpBB extension deve
3939
##### Browsers
4040
QuickInstall is designed to run on all modern browsers. Please don't use old stuff anymore...seriously.
4141

42-
| | | | | | |
43-
|-|-|-|-|-|-|
44-
| Desktop: | ![Chrome](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/chrome/chrome_32x32.png) 60+ | ![Firefox](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/firefox/firefox_32x32.png) 60+ | ![Safari](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/safari/safari_32x32.png) 12+ | ![Edge](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/edge/edge_32x32.png) 80+ | ![Opera](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/opera/opera_32x32.png) 40+ |
45-
| Mobile: | ![iOS](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/safari-ios/safari-ios_32x32.png) 12+ | ![Android](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/android-webview/android-webview_32x32.png) 6+ | | | |
42+
| | | | | | |
43+
|----------|---------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
44+
| Desktop: | ![Chrome](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/chrome/chrome_32x32.png) 60+ | ![Firefox](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/firefox/firefox_32x32.png) 60+ | ![Safari](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/safari/safari_32x32.png) 12+ | ![Edge](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/edge/edge_32x32.png) 80+ | ![Opera](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/opera/opera_32x32.png) 40+ |
45+
| Mobile: | ![iOS](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/safari-ios/safari-ios_32x32.png) 12+ | ![Android](https://cdnjs.cloudflare.com/ajax/libs/browser-logos/69.0.4/android-webview/android-webview_32x32.png) 6+ | | | |
4646

4747
##### phpBB Requirements
4848
phpBB boards require a web server running PHP and one of the following database management systems.
@@ -59,13 +59,28 @@ phpBB boards require a web server running PHP and one of the following database
5959

6060
## QuickInstall CLI
6161

62-
QuickInstall now includes a Docker-based CLI for creating local phpBB test boards. It writes generated state to `.qi/` and leaves the legacy web UI unchanged. The QuickInstall CLI requires PHP 8.0 or newer for the `php bin/qi` command.
62+
QuickInstall now includes a cross-platform, Docker-based CLI and local sandbox web UI for creating phpBB test boards. They work on macOS, Linux, and native Windows and write generated state to `.qi/` without changing the legacy web application.
63+
64+
Sandbox requirements:
65+
66+
- Docker Desktop, installed and running
67+
- PHP 8.0 or newer for the CLI command
68+
- Git when using Git sources
69+
70+
Create your first new board:
6371

6472
```bash
6573
php bin/qi init
6674
php bin/qi board:create test --phpbb 3.3 --db mariadb --port 8081 --populate extension-dev
6775
```
6876

77+
The examples use `php bin/qi`, which works on every supported operating system when PHP is in `PATH`. Windows users can alternatively use the supplied PowerShell or Command Prompt launchers:
78+
79+
```powershell
80+
.\bin\qi.ps1 board:list
81+
.\bin\qi.cmd board:list
82+
```
83+
6984
The QuickInstall CLI targets phpBB 3.2+ installer-based boards. phpBB 3.0/3.1 remain legacy-web-app territory and are not planned for the QuickInstall CLI.
7085

7186
Downloaded extensions can be unzipped into `customisations/` and mounted into boards:

bin/qi.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
php "%~dp0qi" %*
3+
exit /b %ERRORLEVEL%

bin/qi.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$qi = Join-Path $PSScriptRoot 'qi'
2+
& php $qi @args
3+
exit $LASTEXITCODE

docs/sandbox-cli.md

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,32 @@ Then open the URL printed by the command:
6060
http://127.0.0.1:8079/
6161
```
6262

63+
## Commands by OS
64+
65+
The examples in this guide use the portable command form:
66+
67+
```bash
68+
php bin/qi <command>
69+
```
70+
71+
It works on macOS, Linux, and Windows when PHP is available in `PATH`.
72+
73+
Native Windows launchers are also included. From PowerShell:
74+
75+
```powershell
76+
.\bin\qi.ps1 <command>
77+
```
78+
79+
From Command Prompt:
80+
81+
```batch
82+
bin\qi.cmd <command>
83+
```
84+
85+
Arguments and options are identical with every launcher. Run commands from the QuickInstall project root. Windows drive-letter paths, UNC paths, backslashes, spaces, and case-insensitive filesystem paths are supported.
86+
87+
Docker Desktop on Windows must use its WSL 2 or Hyper-V Linux-container backend rather than Windows containers.
88+
6389
## Common Recipes
6490

6591
Create a small empty board:
@@ -219,6 +245,12 @@ By default, extension sources must live under `customisations/`. To mount a trus
219245
php bin/qi ext:mount demo /path/to/vendor/extname --allow-external
220246
```
221247

248+
On Windows, quote external paths containing spaces:
249+
250+
```powershell
251+
.\bin\qi.ps1 ext:mount demo "C:\Path\To\My Extensions\vendor\extname" --allow-external
252+
```
253+
222254
## Styles
223255

224256
Put downloaded styles under `customisations/`:
@@ -266,6 +298,12 @@ By default, style sources must live under `customisations/`. To mount a trusted
266298
php bin/qi style:mount demo /path/to/stylename --allow-external
267299
```
268300

301+
On Windows, quote external paths containing spaces:
302+
303+
```powershell
304+
.\bin\qi.ps1 style:mount demo "C:\Path\To\My Styles\stylename" --allow-external
305+
```
306+
269307
## Supported phpBB Versions
270308

271309
Show supported selectors:
@@ -345,7 +383,7 @@ Fetched sources live under:
345383

346384
## Web UI
347385

348-
QuickInstall includes a local browser UI for the same sandbox workflows exposed by the CLI. It is served by PHP's built-in web server and backed by the same `.qi/` project state.
386+
QuickInstall includes a local browser UI for the same sandbox workflows exposed by the CLI. It is served by PHP's built-in web server and backed by the same `.qi/` project state. The UI server can be started, checked, restarted, and stopped on macOS, Linux, or native Windows.
349387

350388
Start the UI:
351389

@@ -390,15 +428,16 @@ php bin/qi ui:start --host ::1
390428

391429
Generated state:
392430

393-
| Path | Contents |
394-
|------------------------|----------------------------------------------|
395-
| `.qi/boards/<name>` | Installed phpBB board files |
396-
| `.qi/runtime/<name>` | Docker Compose, Dockerfile, installer config |
397-
| `.qi/db/<name>` | Database files |
398-
| `.qi/sources/<source>` | Downloaded phpBB source |
399-
| `.qi/runtime/ui.json` | Tracked web UI server state |
400-
| `.qi/runtime/ui.log` | Web UI server log |
401-
| `.qi/cache/` | Cached update-check metadata |
431+
| Path | Contents |
432+
|--------------------------|----------------------------------------------|
433+
| `.qi/boards/<name>` | Installed phpBB board files |
434+
| `.qi/runtime/<name>` | Docker Compose, Dockerfile, installer config |
435+
| `.qi/db/<name>` | Database files |
436+
| `.qi/sources/<source>` | Downloaded phpBB source |
437+
| `.qi/runtime/ui.json` | Tracked web UI server state |
438+
| `.qi/runtime/ui.log` | Web UI server output log |
439+
| `.qi/runtime/ui.log.err` | Windows web UI server error log |
440+
| `.qi/cache/` | Cached update-check metadata |
402441

403442
User-managed drop zone:
404443

@@ -419,10 +458,34 @@ customisations/
419458

420459
## Troubleshooting
421460

461+
If QuickInstall is not working as expected, start with the environment check:
462+
463+
```bash
464+
php bin/qi doctor
465+
```
466+
467+
Every check should report `OK`; failures include the detected problem. On Windows, use `.\bin\qi.ps1 doctor` or `bin\qi.cmd doctor`.
468+
469+
#### Command is not found on Windows
470+
471+
Run QuickInstall from the project root with one of the supplied launchers:
472+
473+
```powershell
474+
.\bin\qi.ps1 help
475+
```
476+
477+
```batch
478+
bin\qi.cmd help
479+
```
480+
481+
If either launcher reports that `php` is not recognized, install PHP 8 or newer and add its directory to the Windows `PATH`. Open a new terminal and run `php --version` to confirm it is available.
482+
422483
#### Docker command fails
423484

424485
Check that Docker Desktop is running and that the docker command works in this terminal.
425486

487+
On Windows, also confirm Docker Desktop is using Linux containers. `php bin/qi doctor` reports `Linux containers: OK` when configured correctly.
488+
426489
#### Composer command fails
427490

428491
QuickInstall uses composer from PATH first, then `composer.phar` from the project root. Restore `composer.phar` or install Composer if both are missing.
@@ -466,4 +529,4 @@ If the selected port is already in use, choose a different local port:
466529
php bin/qi ui:start --port 8088
467530
```
468531

469-
The UI server log is written to `.qi/runtime/ui.log`.
532+
The UI server output log is written to `.qi/runtime/ui.log`. On Windows, PHP server errors are written to `.qi/runtime/ui.log.err`.

src/QuickInstall/Sandbox/Application.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public function run(array $argv): int
4949
case 'init':
5050
return $this->init();
5151

52+
case 'doctor':
53+
return $this->doctor();
54+
5255
case 'source:list':
5356
return $this->sourceList();
5457

@@ -390,12 +393,31 @@ private function shouldPrompt(): bool
390393

391394
if (defined('STDIN') && $this->stdin === STDIN)
392395
{
396+
if (function_exists('stream_isatty'))
397+
{
398+
return stream_isatty(STDIN);
399+
}
393400
return !function_exists('posix_isatty') || posix_isatty(STDIN);
394401
}
395402

396403
return true;
397404
}
398405

406+
private function doctor(): int
407+
{
408+
$checks = (new DoctorService($this->project))->checks();
409+
$failed = false;
410+
echo "QuickInstall requirements\n";
411+
foreach ($checks as $check)
412+
{
413+
$status = $check['ok'] ? 'OK' : 'FAIL';
414+
echo "[$status] {$check['name']}: {$check['detail']}\n";
415+
$failed = $failed || !$check['ok'];
416+
}
417+
418+
return $failed ? 1 : 0;
419+
}
420+
399421
private function style(string $text, string $code): string
400422
{
401423
if (!$this->supportsAnsi())
@@ -417,6 +439,14 @@ private function supportsAnsi(): bool
417439
{
418440
return posix_isatty(STDOUT);
419441
}
442+
if (function_exists('stream_isatty') && defined('STDOUT') && !stream_isatty(STDOUT))
443+
{
444+
return false;
445+
}
446+
if (PHP_OS_FAMILY === 'Windows' && function_exists('sapi_windows_vt100_support') && defined('STDOUT'))
447+
{
448+
return sapi_windows_vt100_support(STDOUT);
449+
}
420450

421451
return PHP_SAPI === 'cli';
422452
}
@@ -897,6 +927,17 @@ private function printHelpRows(array $rows): void
897927
private function helpCommands(): array
898928
{
899929
return [
930+
'Setup commands' => [
931+
'doctor' => [
932+
'title' => 'doctor',
933+
'usage' => 'doctor',
934+
'summary' => 'Check local PHP, Docker, Git, and Composer requirements.',
935+
'description' => 'Checks that required host tools are available, Docker Desktop is running, Docker Compose works, and Docker is using Linux containers.',
936+
'examples' => [
937+
'doctor',
938+
],
939+
],
940+
],
900941
'Board commands' => [
901942
'board:create' => [
902943
'title' => 'board:create',

src/QuickInstall/Sandbox/DockerComposeWriter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public function write(string $name, array $config): array
3838
file_put_contents($compose, $this->compose($name, $config));
3939
file_put_contents($dockerfile, $this->dockerfile($config));
4040
file_put_contents($entrypoint, $this->entrypoint());
41-
chmod($entrypoint, 0755);
41+
if (PHP_OS_FAMILY !== 'Windows')
42+
{
43+
chmod($entrypoint, 0755);
44+
}
4245

4346
return [
4447
'compose' => $compose,

0 commit comments

Comments
 (0)