Skip to content

Cron jobs fail on Windows when PHP_BINARY path contains spaces #109

@johnakis45

Description

@johnakis45

Environment

  • Crunz version: 3.7^
  • PHP version: 7.4 and later
  • OS: Windows 10 Pro or later

Description

On Windows, if your PHP CLI binary lives in a directory whose path contains spaces (for example, C:\Program Files\PHP\php.exe), scheduled tasks will silently fail. The command-line builder in src/Event.php (around line 1165) doesn’t wrap the PHP_BINARY constant in quotes, so Windows tries to execute C:\Program instead of the full C:\Program Files\PHP\php.exe.


How to reproduce

  1. Install PHP 8.0+ under a path with spaces (e.g. C:\Program Files\PHP\php.exe).
  2. Include a minimal schedule in your project (e.g. a crunz.yml that writes output to a file or stdout).
  3. From a CMD or PowerShell prompt, run:
    php vendor/bin/crunz schedule:run

4.Observe that nothing happens and no error appears, because Windows cannot locate the (unquoted) executable.

Expected behavior

Crunz should wrap PHP_BINARY in quotes so that Windows can correctly invoke the full path, and the scheduled task runs as intended.

Actual behavior

No tasks run and no errors are reported; Windows attempts to execute the truncated path up to the first space.

Workaround

Manually patch src/Event.php (around L1165) in your vendor copy to wrap the binary in quotes, or install PHP into a path without spaces.

Possible solution

Change this line in src/Event.php:

PHP_BINARY . " {$crunzRoot} closure:run {$serializedClosure}";

to:

'"' . PHP_BINARY . '"' . " {$crunzRoot} closure:run {$serializedClosure}";

This ensures the full PHP path is quoted on Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions