Skip to content

feat: sandbox per solution, made by a SandboxFactory - #345

Merged
AydinHassan merged 10 commits into
masterfrom
sandbox-picks-port
Nov 1, 2026
Merged

AydinHassan merged 10 commits into
masterfrom
sandbox-picks-port

Conversation

@AydinHassan

@AydinHassan AydinHassan commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Three levels, each makes the next:

  • SandboxFactory: one for the app (HostSandboxFactory, DockerSandboxFactory). Holds the setup, eg. docker binary, image, network, port picker. create($directory, $scenario) gives a Sandbox.
  • Sandbox: one per solution, reference and student (HostSandbox, DockerSandbox). Holds its directory and port. execute(ProcessInput) gives a SandboxExecution, getPort() the port its code listens on.
  • SandboxExecution: one run, a single class for both. start, wait, output, getAddress().

The exercise only says it needs a port: ->exposePort(). The factory picks it per solution: HostSandboxFactory one free on this machine, DockerSandboxFactory with its PortPicker, published the same inside and out, -p host:N:N.

The pre events carry the solution's sandbox, so the exercise puts the port in its args wherever it wants: $event->getSandbox()->getPort(). The executing events carry the execution: $event->getExecution()->getAddress().

Also:

  • ProcessInput is just the command: executable, args, env, stdin.
  • Folders: Process\\Sandbox (the three levels and ProcessInput), Process\\Sandbox\\Host, Process\\Sandbox\\Docker, Process\\Port (port pickers).

@AydinHassan AydinHassan changed the title feat: sandbox picks the port exercises listen on feat: sandbox prepares a workspace per solution, with its port Nov 1, 2026
@AydinHassan AydinHassan changed the title feat: sandbox prepares a workspace per solution, with its port feat: sandbox per solution, made by a SandboxFactory Nov 1, 2026
@AydinHassan
AydinHassan merged commit 634a0c0 into master Nov 1, 2026
6 checks passed
AydinHassan added a commit to php-school/phpschool.io that referenced this pull request Nov 1, 2026
Updates php-workshop to
php-school/php-workshop#345 and learn-you-php /
php8-appreciate to their latest `workshop-rewrite`.

- `DockerSandbox` is now `DockerSandboxFactory`, bound as
`SandboxFactory`.
- Port pickers moved to `Process\\Port`.
- Fixes Time Server on the website: the lock pinned an old learn-you-php
that used an API php-workshop no longer has. It now uses
php-school/learn-you-php@834b6dd.
@AydinHassan AydinHassan mentioned this pull request Nov 1, 2026
3 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant