Repository navigation
feat: sandbox per solution, made by a SandboxFactory - #345
Merged
Merged
Conversation
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.
3 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 aSandbox.Sandbox: one per solution, reference and student (HostSandbox,DockerSandbox). Holds its directory and port.execute(ProcessInput)gives aSandboxExecution,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:
ProcessInputis just the command: executable, args, env, stdin.Process\\Sandbox(the three levels and ProcessInput),Process\\Sandbox\\Host,Process\\Sandbox\\Docker,Process\\Port(port pickers).