Skip to content

fix(php): ignore warnings in CLI parsing #1527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

saibotk
Copy link
Contributor

@saibotk saibotk commented Jul 14, 2025

When running PHP with extensions like imagick, sometimes the extension needs a rebuild after brew upgrade. Otherwise, it will throw a warning:

Warning: Version warning: Imagick was compiled against ImageMagick version 1809 but version 1810 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0

This warning is also printed, within the shell executions in Valet. But we use the output of those PHP CLI invocations. With those warnings being printed out, the parsing on the output fails and Valet cannot be used until the pecl extension is rebuilt.

With this patch, all CLI PHP invocations use -d error_reporting=1. This suppresses warnings, but will still report errors.

It makes valet more robust in case a system package update causes warnings.

When running PHP with extensions like imagick, sometimes the extension needs a rebuild after `brew upgrade`.
Otherwise, it will throw a warning:
```
Warning: Version warning: Imagick was compiled against ImageMagick version 1809 but version 1810 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0
```

This warning is also printed, within the shell executions in Valet.
But we use the output of those PHP CLI invocations.
With those warnings being printed out, the parsing on the output fails and Valet cannot be used until the pecl extension is rebuilt.

With this patch, all CLI PHP invocations use ` -d error_reporting=1`.
This suppresses warnings, but will still report errors.

It makes valet more robust in case a system package update causes warnings.
@mattstauffer
Copy link
Collaborator

Looks good to me initially. @drbyte any concerns before I merge?

@drbyte
Copy link
Contributor

drbyte commented Jul 16, 2025

This is probably the best-available approach. We can't automate the re-install of all possible extensions without adding a lot of complexity due to unpredictability. And suppression of warnings (to prevent undesired excess verbage) but not errors (where we do want a failure to be reported) makes the best sense, particularly in the use-cases where this PR has introduced changes (where Valet is asking PHP for some information that's largely unaffected by and immaterial to any warnings PHP itself may be encountering).

So @mattstauffer I'll give it a yes. 👍

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