Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider using
php://stderr
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is for local development only, I find the message just noisy and unnecessary, but no strong feelings either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting, I think this surfaces 2 different problems:
STDERR
is supposed to be a PHP constant, but it's not always definedRegarding 1, the docs mention these constants should be available:
But this bug suggests they should only exist in CLI environments: https://bugs.php.net/bug.php?id=69452 So that makes a bit more sense in retrospect.
That being said, since the constant doesn't always exist, I think we shouldn't rely on it, and we should mess with it (re-define it) since we cannot cover scenarios when running outside of Lambda/Bref-controlled environment.
So I'd suggest we move away from the constant and go with @tillkruss's suggestion.
Regarding 2, we could disable the log message in local development?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my PR achieves exactly that. When running inside Lambda,
bref-init.php
runs so the constant is always available https://github.com/brefphp/laravel-bridge/blob/master/src/bref-init.php#L10-L12When running on local, the constant may not be available (because
Bref::beforeStartup()
didn't run) and since the constant is not defined, it will not attept to write to stderr.Btw, sorry for the delay on answering, for some reason I'm not getting email notification about this PR even though I'm subscribed to it 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is that, given a choice, I'd rather not merge this PR as it will create extra work down the road when/if we solve problem 1.
Is there any other way we can solve 2 ("disable the log message in local development") with a different solution that doesn't rely on checking whether
STDERR
is defined?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mnapoli thanks now I got it! Smart thinking. Given the clarity I would go back to my first comment and say 2) is not that important. If you ever solve for 1) and suddenly my local starts popping up a message right when containers start up, it's not the end of the world. I guess what I'm saying is that this PR avoids a crash and hides an unimportant message. If the crash is avoided by a guaranteed of the constant being defined then the unimportant message starts showing up but the crash is still avoided, so no harm done.
At the end of the day I want 3) don't crash if you can't write an unimportant message. So I will get 2) and 3) with this PR and later this might get swapped into 1) and 3) instead, which seems to me better than involving an environmental check here.
Let me know your thoughts after this and I will work out something accordingly. I think that there won't be any new insights afterwards and we can come to a conclusion on the preference and move forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 makes sense, yeah 1 is the most important part indeed!