Skip to content

Pre-release 4.2.121 → 4.2.120 — task 4.5 (foundation): boot through v13's application builder and entry points - #94

Merged
agissept merged 1 commit into
masterfrom
pre-release/4.2.121
Oct 5, 2026
Merged

agissept merged 1 commit into
masterfrom
pre-release/4.2.121

Conversation

@oonid

@oonid oonid commented Oct 1, 2026 •

Copy link
Copy Markdown

Task 4.5, foundation — boot through v13's application builder and entry points

Stacks on #93. This is the first foundation slice: the bootstrap rewrite in task 4.5 of MIGRATION-TASKS.md. Stock Foundation only ships inside laravel/framework, so it can't be swapped in package by package. Instead the fork gives the app v13's bootstrap surface, with v13's names and signatures. The dicoding app pair moves bootstrap/app.php, public/index.php, artisan and its test base onto it, and those files need no change at the flip.

Changes

  • Application::configure($basePath) returns a new Configuration\ApplicationBuilder with three of v13's methods:

    • withMiddleware() fills the global middleware list.
    • withExceptions() configures the handler once it first resolves, as in v13.
    • create() returns the application.
  • Paths:

    • setBasePath() binds v13's app, public and storage paths under the base path. path.lang stays at app/lang.
    • useStoragePath() overrides storage.
    • bindInstallPaths() is removed.
  • Entry points:

    • handleRequest() replaces run().
    • handleCommand() replaces the artisan script's setRequestForConsoleEnvironment() + make('artisan')->run().
  • Lazy start: start.php now runs once, the first time a request, a command or the console Kernel's bootstrap() needs it, in place of v13's kernel bootstrappers.

    • The environment defaults to production, as in v13.
    • start.php no longer reads the $unitTesting/$testEnvironment globals; tests set the environment on the application.
  • Console Kernel contract: the Artisan wrapper is bound from construction and answers v13's console Kernel bootstrap() and handle(). So tests can bootstrap the way v13's TestCase does: $app->make(Kernel::class)->bootstrap(). ArtisanServiceProvider keeps only its two commands.

  • Tests: a new FoundationApplicationBuilderTest (8 tests) runs against a throwaway base path, with a minimal config, route file and artisan.php:

    • configure() binds the v13 paths;
    • withMiddleware() and withExceptions() work, the latter lazily;
    • the console Kernel bootstraps once, and the environment defaults to production;
    • handleRequest() bootstraps, sends the response through the global middleware and terminates;
    • handleCommand() runs a command with the console request and returns its status;
    • run() and bindInstallPaths() are gone.

    The old run() test moves there as the handleRequest() test.

Verification

  • Fork: the suite is 273 green on PHPUnit 11.5.56. The ratchet is green, with every pattern at its baseline.
  • The new tests catch real breaks. Each of these 9 mutations fails at least one test:
    • running the start script twice;
    • dropping the production default;
    • not terminating;
    • not trimming the base path;
    • applying exceptions eagerly;
    • not applying middleware;
    • skipping the console request;
    • dropping the command status;
    • not binding the console Kernel before bootstrap.
  • Downstream: the dicoding app pair is dicoding-dev/dicoding#5997 (feature/platform/framework-4.2.121-rc1). It replaces bootstrap/start.php with a v13 bootstrap/app.php, and moves public/index.php, artisan and its test base onto handleRequest(), handleCommand() and the console Kernel. It ran with vendor installed exactly from its lock:
    • Psalm (full project, no cache): no errors.
    • Unit suite: 8962 green.
    • Integration suite: all 3022 tests. Only the 4 long-standing failures remain, after rerunning the Command tests that first ran while the local mail sink was down. 196 are skipped, and no test is flagged risky.
    • The real entry points were compared with 4.2.120: php -S + server.php → index.php for 6 requests, and 7 artisan commands. Statuses, bodies, headers, cookies, command output and exit codes are identical. So are the 13 in-process cookie/session/error-page scenarios.
  • Checks ran in a cloud container without deck (PHP 8.4.26, MariaDB 10.11).

Tag

4.2.121 (c0c37038) is not pushed, and neither are 4.2.119 (c95ae41d) or 4.2.120 (14026a74). Tag pushes are refused for this session.

🤖 Generated with Claude Code

https://claude.ai/code/session_0169SsatCE8LhaTsQTPiGtVo

@agissept
agissept force-pushed the pre-release/4.2.121 branch from c0c3703 to 26d05f3 Compare October 2, 2026 09:20
@agissept
agissept added this pull request to stack #102 October 5, 2026 06:14
@agissept
agissept force-pushed the pre-release/4.2.121 branch from 26d05f3 to 9adb5c1 Compare October 5, 2026 06:14
Base automatically changed from pre-release/4.2.120 to master October 5, 2026 07:10
…ints (task 4.5)

The app's bootstrap moves to v13's shape: bootstrap/app.php builds the
application with Application::configure()->withMiddleware()->withExceptions()
->create(), public/index.php calls handleRequest() and artisan calls
handleCommand(). The fork provides that surface with v13's names and
signatures, so those files need no change at the flip:

- Application::configure($basePath) returns a Configuration\ApplicationBuilder.
  withMiddleware() fills the global middleware; withExceptions() configures the
  handler once it resolves, as in v13. setBasePath() binds v13's app, public and
  storage paths (path.lang stays at app/lang); useStoragePath() overrides storage.
- handleRequest() and handleCommand() replace run() and the artisan script's
  setRequestForConsoleEnvironment() + make('artisan')->run().
- The L4.2 start script now runs lazily, once, when a request, a command or the
  console Kernel's bootstrap() first needs it, standing in for v13's kernel
  bootstrappers. The environment defaults to production, as in v13; tests set
  it on the application instead of start.php's $unitTesting globals.
- The Artisan wrapper is bound from construction and answers v13's console
  Kernel bootstrap() and handle(), so tests can bootstrap the way v13's
  TestCase does. ArtisanServiceProvider keeps only its two commands.
- bindInstallPaths() and run() are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0169SsatCE8LhaTsQTPiGtVo
@agissept
agissept marked this pull request as ready for review October 5, 2026 07:26
@agissept
agissept force-pushed the pre-release/4.2.121 branch from 9adb5c1 to 799ccab Compare October 5, 2026 07:26
@agissept
agissept merged commit 7295e7c into master Oct 5, 2026
2 checks passed
@agissept
agissept deleted the pre-release/4.2.121 branch October 5, 2026 08:39
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.

3 participants