I'm investigating the possibility of symmetrically encrypting native streams in PHP. I've found lots of information showing how to perform this sort of encryption on normal strings (entirely in memory) using modern and recommended libraries such as sodium and openssl, but the only mention I've discovered about encrypting native PHP streams is here but that page and the comments suggest that not using it is safer (and it's marked as deprecated).
I haven't been able to find practical examples of how to use native PHP encryption filters on streams doing it safely.
I've found this library which works on the Guzzle PSR-7 stream object but not on native PHP streams. Unfortunately this isn't interoperable with other libraries which expect native streams.
I'm interested in streams as opposed to encrypting full files because that avoids all memory and size limits.
Is encryption on streams possible using stream encryption filters as mentioned in the docs but just not recommended and deprecated because it's so easy to get wrong or is it simply not possible to do securely?