Skip to content

fix(cli): preload project autoloader in bin#10

Merged
markshust merged 4 commits intomarko-php:developfrom
jasonjpeters:fix/issue-8-global-cli-class-not-found
Apr 5, 2026
Merged

fix(cli): preload project autoloader in bin#10
markshust merged 4 commits intomarko-php:developfrom
jasonjpeters:fix/issue-8-global-cli-class-not-found

Conversation

@jasonjpeters
Copy link
Copy Markdown
Contributor

@jasonjpeters jasonjpeters commented Apr 3, 2026

Summary

This PR fixes a CLI bootstrap issue where running marko could fail with "Error: Class "Marko\Core\Command\Output" not found.

The root cause was that the bin script could construct and run CliKernel before the project's own autoloader was loaded. Since CliKernel depends on project classes from marko/core, those classes were not always available at startup. The fix updates packages/cli/bin/marko to resolve the project root first and preload the project vendor/autoload.php before booting the kernel.

The PR also updates packages/cli/tests/BinMarkoTest.php so the test suite reflects the new bootstrap flow, including coverage for ProjectFinder usage, conditional project autoloader loading, and the direct inline kernel execution path. The CLI package tests pass with this change.

tests/IntegrationVerificationTest.php

The tests/IntegrationVerificationTest.php changes were made to make the integration test portable and truly isolated.

The test previously assumed a macOS-specific PHP path and also deleted the live project vendor/ directory while Pest was still running from it. That caused failures on non-macOS systems and runtime fatals like Class "Pest\Panic" not found. The fix switches to PHP_BINARY so the current interpreter is used on any OS, and runs the destructive Composer workflow in a temporary copy of the repo so the active test process is never corrupted.

packages/dev-server/tests/Command/DevDownCommandTest.php

The packages/dev-server/tests/Command/DevDownCommandTest.php changes make the dev:down process-group test resilient to normal Unix process cleanup timing. The original test asserted that the process group disappeared immediately after sending the stop signal, but on Linux the terminated parent can briefly remain as a zombie until it is reaped, causing the group to still appear alive.

The test was updated to proc_close() the spawned parent before the final assertion and to add a short retry loop when checking isProcessGroupRunning(). This keeps the intent of the test the same while avoiding a false failure caused by process reaping timing rather than shutdown behavior.

bin/release.sh, tests/ReleaseScriptTest.php, .claude/release-process.md

Removed the hardcoded macOS Homebrew PHP path (/opt/homebrew/Cellar/php/8.5.1_2/bin/php) from the release script, its test, and release process docs. The release script now uses ${PHP_BIN:-php}, allowing contributors to either set a PHP_BIN env var or rely on php being on their PATH. The PHP 8.5+ version check still runs and will abort with a helpful message if the wrong version is found.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Docs
  • Refactor

Related Issues

Closes #8

Checklist

  • Tests pass (./vendor/bin/pest --parallel)
  • Lint passes (./vendor/bin/phpcs)
  • Follows code standards

@github-actions github-actions bot added bug Something isn't working breaking Introduces a breaking change and removed bug Something isn't working labels Apr 3, 2026
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Apr 3, 2026
@jasonjpeters jasonjpeters marked this pull request as ready for review April 3, 2026 23:42
The release script and its tests referenced a macOS-specific Homebrew
PHP path. This replaces it with `${PHP_BIN:-php}` so any contributor
can override via env var or rely on their PATH.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Apr 5, 2026
@markshust markshust merged commit 7fddb2a into marko-php:develop Apr 5, 2026
1 check passed
@jasonjpeters jasonjpeters deleted the fix/issue-8-global-cli-class-not-found branch April 6, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Introduces a breaking change bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Global marko CLI fails with class not found when run from project

2 participants