Skip to content
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

[10.x] Add syntax sugar to the Process::pipe method #46745

Merged
merged 3 commits into from
Apr 11, 2023

Conversation

WendellAdriel
Copy link
Contributor

What changes

This adds a syntax sugar for the Process::pipe, allowing it to run simple commands without configuration like this:

$result = Process::pipe([
    'cat test',
    'grep -i "foo"',
]);

$result->output(); // "foo"

Taking into consideration that the content of test.txt will be:

Hello, world
foo

Why

This idea was shared by @nunomaduro on Twitter: https://twitter.com/enunomaduro/status/1645805234151895041 and I think this can be a simple way to run a pipeline of simple commands when we don't need to configure the commands to run.

Implementation Details

I thought about creating a SimplePipe class to not reuse the Pipe class for this, but IDK if that's a good idea. I'd love to get feedback and update the PR if needed.

@nunomaduro nunomaduro marked this pull request as draft April 11, 2023 16:53
@taylorotwell taylorotwell marked this pull request as ready for review April 11, 2023 16:56
@WendellAdriel
Copy link
Contributor Author

Thanks, @nunomaduro and @taylorotwell.
That makes much more sense.

@taylorotwell
Copy link
Member

I updated it. @WendellAdriel

@WendellAdriel
Copy link
Contributor Author

Oh, just saw the changes now
I was going to do it, but thanks for helping me on this, @taylorotwell! You rock!!! 🤘

@taylorotwell taylorotwell merged commit 9f08dd7 into laravel:10.x Apr 11, 2023
@WendellAdriel WendellAdriel deleted the process-pipe-sugar branch April 11, 2023 17:10
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