Free preview.You're sampling one lesson — enroll free to unlock all 8 lessons and track your progress.
Enroll free
lesson

Concurrency vs. Parallelism

Concurrency vs. Parallelism

In this lesson — part of Concurrency Basics — you'll learn concurrency vs. parallelism in PHP and why it matters in real work.

Why it matters

Modern programs wait on networks and disks — async lets them stay responsive.

Key ideas

  • Blocking vs. non-blocking
  • Callbacks, promises, async/await
  • Concurrency vs. parallelism
  • Error handling in async code

In practice

Here's how it looks in idiomatic PHP:

<?php
// Fibers (PHP 8.1+) are the native cooperative-async primitive
$fiber = new Fiber(function (): void {
    $resume = Fiber::suspend("paused");   // yield control
    echo "resumed with: $resume" . PHP_EOL;
});

$value = $fiber->start();   // "paused"
$fiber->resume("go");       // prints: resumed with: go

PHP note: PHP has no async/await keyword; Fiber (8.1+) provides the low-level suspend/resume primitive that event-loop libraries like ReactPHP and Amp build coroutines on.

Try it yourself

Exercise: In PHP, fetch two things concurrently and combine the results.

Recap

You now understand concurrency vs. parallelism and can apply it in PHP. Mark this lesson complete and continue to the next one.