Is it possible that PHP will ever get async/await functions?

This page summarizes the projects mentioned and recommended in the original post on /r/PHP

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • promises

    Promises/A+ library for PHP with synchronous support

  • ext-openswoole

    Programmatic server for PHP with async IO, coroutines and fibers

  • These can be performed concurrently in PHP with Swoole https://openswoole.com/

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • React

    Event-driven, non-blocking I/O with PHP.

  • Dunno about PHP core, but there is also ReactPHP. https://reactphp.org/

  • Amp

    A non-blocking concurrency framework for PHP applications. 🐘

  • If you want async/await behavior in PHP, you have https://amphp.org/amp/.

  • async

    Async utilities and fibers for ReactPHP. (by reactphp)

  • Promises are a solution to asynchronicity in general. Promises are more of a specification, so anything claiming to implement Promises solves the same class of problem in the same way. Since php doesn't have language level wrappers for Await behavior it is going to look weird. Either you use something Object Oriented like Promises to handle the timing/async of your calls, or you use something functional like the pcntl functions to handle Process Control of multiple interdependent processes and the pipes/sockets between them. There are also separate Asnycronous libraries available that have a slightly different interface, but they probably just use promises in the backend. See https://github.com/reactphp/async and https://github.com/reactphp/promise for instance if you don't like curl.

  • promise

    Promises/A implementation for PHP. (by reactphp)

  • Promises are a solution to asynchronicity in general. Promises are more of a specification, so anything claiming to implement Promises solves the same class of problem in the same way. Since php doesn't have language level wrappers for Await behavior it is going to look weird. Either you use something Object Oriented like Promises to handle the timing/async of your calls, or you use something functional like the pcntl functions to handle Process Control of multiple interdependent processes and the pipes/sockets between them. There are also separate Asnycronous libraries available that have a slightly different interface, but they probably just use promises in the backend. See https://github.com/reactphp/async and https://github.com/reactphp/promise for instance if you don't like curl.

  • parallel

    An advanced parallelization library for PHP, enabling efficient multitasking, optimizing resource use, and application responsiveness through multiple CPU threads. (by amphp)

  • You can leverage https://github.com/amphp/parallel or https://github.com/spatie/async without changing the app much.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • async

    Easily run code asynchronously (by spatie)

  • You can leverage https://github.com/amphp/parallel or https://github.com/spatie/async without changing the app much.

  • asynchronous-php

    List of resources for asynchronous programming in PHP

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts