daily-email: add 2023-04-23
This commit is contained in:
parent
e2fccef0ad
commit
9002c44433
28
src/content/daily-email/2023-04-23.md
Normal file
28
src/content/daily-email/2023-04-23.md
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
title: >
|
||||||
|
Laravel Pipelines
|
||||||
|
pubDate: 2023-04-23
|
||||||
|
permalink: >
|
||||||
|
archive/2023/04/23/laravel-pipelines
|
||||||
|
tags:
|
||||||
|
- php
|
||||||
|
- laravel
|
||||||
|
---
|
||||||
|
|
||||||
|
I've seen a lot on social media and posts and videos recently about Laravel Pipelines - functionality that's been present in Laravel and used within the framework for some time - but there was only documentation added for it last month as part of the Laravel 10 release.
|
||||||
|
|
||||||
|
This is an example from the new documentation:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$user = Pipeline::send($user)
|
||||||
|
->through([
|
||||||
|
GenerateProfilePhoto::class,
|
||||||
|
ActivateSubscription::class,
|
||||||
|
SendWelcomeEmail::class,
|
||||||
|
])
|
||||||
|
->then(fn (User $user) => $user);
|
||||||
|
```
|
||||||
|
|
||||||
|
Once a user has registered, it is passed through different classes - each performing a task and calling the next class in the list, similar to middleware. Once finished, a final action is performed or a value is returned.
|
||||||
|
|
||||||
|
As someone who doesn't use Laravel often but does use standalone components - like `illuminate/collections` - in other PHP projects, I'm interested to see how I can use this via `illuminate/pipeline` to refactor some of my existing code.
|
Loading…
Reference in a new issue