Skip to content

Support callback for output #199

@hschletz

Description

@hschletz

Description of the problem

Output is done to a stream, STDOUT by default, but can be set to an arbitrary stream.

Sometimes this is not flexible enough. For example, I want to write to 2 streams simultaneously. There may also be situations where a stream is not supported by a particular output method.

This could be solved by a custom stream wrapper or filter, but a callback for output would be much simpler. Would it be possible to support that?

Example code

// Example for new callback option. Overrides default stream output.
$options = new ZipStream\Option\Archive();
$options->setOutputCallback(function ($data) {
    write_output($data);
});

Activity

maennchen

maennchen commented on Feb 24, 2022

@maennchen
Owner

I would welcome an addition, that would support this the following way:

PRs are welcome for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @maennchen@hschletz

      Issue actions

        Support callback for output · Issue #199 · maennchen/ZipStream-PHP