diff --git a/src/content/daily-email/2023-04-23.md b/src/content/daily-email/2023-04-23.md new file mode 100644 index 000000000..a5ad7d2b0 --- /dev/null +++ b/src/content/daily-email/2023-04-23.md @@ -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.