Skip to content

Conversation

@clue
Copy link
Owner

@clue clue commented Jan 3, 2026

This changeset adds support for using a custom runner with a new X_EXPERIMENTAL_RUNNER environment variable. The goal is to allow custom application runners, think queue runners, CRON, a FastCGI server and more.

class AcmeRunner
{
    public function __invoke(callable $app): void
    {
        // 1. receive request
        // 2. call $app($request)
        // 3. send response
    }
}

$container = new FrameworkX\Container([
    // 'X_EXPERIMENTAL_RUNNER' => AcmeRunner::class
    // 'X_EXPERIMENTAL_RUNNER' => fn(bool|string $ACME = false): ?string => $ACME ? AcmeRunner::class : null
    'X_EXPERIMENTAL_RUNNER' => fn(?string $X_EXPERIMENTAL_RUNNER = null): ?string => $X_EXPERIMENTAL_RUNNER,
]);

$app = new FrameworkX\App($container);

Note that this is an experimental feature and the API may be subject to change in future releases. Once PSR-15 is fully integrated (see wish list #293), we may decouple this further to use the PSR-15 RequestHandler API. For now, the callable syntax implemented in #294/#236 should be good enough.

Builds on top of #294, #292, #289, #288, #287, #236, #224, #44, and others

@clue clue added this to the v0.18.0 milestone Jan 3, 2026
@clue clue requested a review from Copilot January 3, 2026 15:19
@clue clue added the new feature New feature or request label Jan 3, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for custom application runners through a new experimental X_EXPERIMENTAL_RUNNER environment variable. This enables users to provide custom runners for advanced use cases like queue runners, CRON jobs, FastCGI servers, and other specialized application execution patterns.

Key changes:

  • Introduced X_EXPERIMENTAL_RUNNER environment variable support in Container::getRunner()
  • Added runtime validation to ensure custom runners are callable
  • Comprehensive test coverage for the new functionality including error cases

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Container.php Modified getRunner() to check for X_EXPERIMENTAL_RUNNER environment variable and validate that returned runner is callable
src/App.php Updated $runner property type annotation and documentation to reflect support for custom callable runners
tests/ContainerTest.php Added three new test cases for custom runner functionality and updated existing test mocks to account for the additional X_EXPERIMENTAL_RUNNER check
tests/AppTest.php Added integration test to verify custom runner is properly invoked via App::run()
docs/best-practices/controllers.md Added documentation example showing how to configure X_EXPERIMENTAL_RUNNER environment variable

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@clue clue force-pushed the experimental-runner branch 3 times, most recently from 734a788 to ab0dd15 Compare January 3, 2026 16:38
@clue clue requested a review from Copilot January 3, 2026 16:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@clue clue force-pushed the experimental-runner branch from ab0dd15 to 5a98992 Compare January 3, 2026 16:56
@clue clue merged commit c310438 into clue:main Jan 3, 2026
68 checks passed
@clue clue deleted the experimental-runner branch January 3, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant