Skip to content
@phasync

phasync

phasync

The phasync framework is a new coroutine library for PHP which works without any extensions. With phasync, you can use asynchronous IO operations while writing code the way you have always done it in PHP.

Running Coroutines

Whenever you need to write code that uses coroutines, you simply use phasync::run(). You can use it in your existing codebase without changing anything else.

class SomeController {

    public function someMethod(): string {
        // Create a context for using async code
        return phasync::run(function() {
            // Write your code here
            $client = new HttpClient();

            // Another coroutine just for fun
            $result = phasync::go(function() {
                for ($i = 0; $i < 10; $i++) {
                    echo "Counting: $i\n";
                    phasync::sleep(0.5);
                }
                return $i;
            });

            // These requests run in parallel
            $request1 = $client->get("http://example.com/");
            $request2 = $client->get("http://example2.com/");

            return [
              $request1,
              $request2,
              phasync::await($result)
            ];
        });
    }

}

Popular repositories Loading

  1. phasync phasync Public

    Micro framework for ultra high performance PHP websites with non-blocking IO.

    PHP 242 7

  2. swerve swerve Public

    SWERVE - the PHP application server

    PHP 13

  3. http-client http-client Public

    An asynchronous HTTP client implementation with the standard PSR-18 interface using Fibers.

    PHP 8

  4. file-streamwrapper file-streamwrapper Public

    Make file IO transparently asynchronous inside phasync PHP coroutines

    PHP 5

  5. http-streamwrapper http-streamwrapper Public

    Make http:// and https:// requests asynchronous inside phasync coroutines

    PHP 1

  6. objectpool objectpool Public

    A library for implementing efficient object pooling.

    PHP 1

Repositories

Showing 9 of 9 repositories

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…