Laravel Pipeline or Pipes: Multiple Actions on Object

preview_player
Показать описание
I want to show you an undocumented feature of Laravel called Pipelines. Share in the comments what you think about it.

- - - - -
Support the channel by checking out our products:
Рекомендации по теме
Комментарии
Автор

The Pipeline is a general definition that is used in most fields, Laravel uses a Pipeline especially in middleware. The middleware is built on this awesome definition to make the request passes through every middleware in order way then return the final result.

mmramadan
Автор

Interesting, I have a large publishing method which has a lot of sub routines for things like preparing assets, creating backups, zipping files and deploying to remote servers, all based on various configurations. Breaking it down using pipes and external classes makes so much more sense.

AndyTalbot
Автор

It's really good to know about Laravel pipelines.

meharwaheed
Автор

I never heard of this before but I like it. I kinda want to try it out for building custom filters for data. Each filter the user turns on adds it to the pipeline, then I just run the piepline. I feel that like would be 1000x cleaner than constant uses of `where()` in a giant query builder instance.

ryanb
Автор

I would never use it, because of the next reasons.
1. Very complicated to test, since pipeline is more a helper method.
2. Violates open/closed principle. As you mentioned 'if somebody wants to add new pipeline' - he would have to touch the original file that calls these pipes, instead of working in separate class.
3. Not the best OOP solution, since link between pipes and a calling class is a helper.

I'd stick to a small stand alone class like 'set of rules' or 'set of actions', which I would call from controller or whatever other class. That solution is clear OOP, with easy testing and doesn't violate open/closed principle.
I don't see any advantage with pipelines, unless you're a big fan chaining methods. Not testable = not best to use.

alexaverkiyev
Автор

This video is amazing, the quality of the examples provided by the community provide different ways to use it, thanks great examples

arielmejia
Автор

The package named Tenancy for Laravel also uses pipelines. I kinda like this technique even though never used it.

bulent
Автор

Very awesome feature, I make use of it whenever I don't want to use 'when' for record filtering. It helps to eliminate if and else statements

joshuaadebayo
Автор

I used the pipeline to filtering the data and it is amazing.

amkashif
Автор

Awesome presentation and best channel for learn laravel..

athulvl
Автор

I have never used this in five years of Laravel, but it might be useful in very specific cases. I can think of a few projects I’ve done that could have benefited from this.

phoenixedge
Автор

Pipeline are great with iostreams, it let you describe how to modify each byte from the input to the output, it makes encryptions/compression easier

soniablanche
Автор

This Feature is really Good, still having confused to understand it. Audience need some solid implementation by you. I hope you will share the practical example that how and where its useful

QaziHamayun
Автор

Great way to refactor of huge services and extract not only objects transformation, but queries if you have big amount of search parameters.

olehtalanov
Автор

Is good to implement the "Chain of Responsabilities" Pattern. I would use it to handle some situation where I'm not sure a priori wich strategy is the best. For example, to determine "location" information, I can use DB if user is logged, Cookies if there is some, HTTP headers if there's information, or IP address.

gustavoayala
Автор

Humm I have a app that used many of filters so this the time to change those filters to pipline classes 🙂🙂

elmarzougui
Автор

I have heard this pipeline but as far I know PHP is a synchronous language that run line by line. So I don't see how's pipeline benefits the process. Can someone explain?

amirulidzham
Автор

sounds goods, but sir, help do your handon coding examples on it for better understanding

taiwoolatmi
Автор

Only got a high level understanding of the usage... Would like to go deeper to implement it...

adarshchacko
Автор

Actually this is well known design pattern - chain responsibility. Just implementation throw Laravel contract

kolyan