---
title: "Discovering PHP's yield Keyword After 10 Years"
url: https://daily.dev/posts/discovering-php-s-yield-keyword-after-10-years-m9c5f2yhg
source_url: https://freek.dev/2830-discovering-phps-yield-keyword-after-10-years
type: article
source: "FREEK.DEV"
published: 2025-03-18T13:07:42.004Z
updated: 2025-03-18T13:07:58.841Z
tags: ["webdev", "php", "laravel"]
reading_time: 1
upvotes: 33
comments: 5
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Discovering PHP's yield Keyword After 10 Years

**[FREEK.DEV](https://daily.dev/sources/freek)** · 1 min read · 33 upvotes · 5 comments

## Summary

Explains PHP's yield keyword and how it can be used instead of return to simplify building iterators. Highlights practical tips and its applications in modern PHP development, particularly with Laravel.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://freek.dev/2830-discovering-phps-yield-keyword-after-10-years>

## Community discussion

Top comments from developers on daily.dev.

**@pasindudissanayaka** · 2 upvotes

> I'm sorry what? Are you new to development? Do you not read documentation?

**@willembraam** · 0 upvotes

> I did not ever have to use this before either. Loved the little article, thanks!

**@ravavyr** · 0 upvotes

> Yield seems nice at first "like, yay it'll continue running the loops!"... until you realize using recursion is better because you can grasp what is happening easier. Just something about how the code runs, how the steps process is easier to grasp with functions/methods than using yield.
>
> At least, for me it is. Also, sticking with one return at the end of each method means the logic runs through to the end, always, it doesn't suddenly skip back halfway through, if that makes any sense to ya.

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 0 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#php](https://daily.dev/tags/php), [#laravel](https://daily.dev/tags/laravel)

[View this post on daily.dev](https://daily.dev/posts/discovering-php-s-yield-keyword-after-10-years-m9c5f2yhg)
