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 237 7

  2. swerve swerve Public

    SWERVE - the PHP application server

    PHP 11

  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
  • phasync Public

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

    phasync/phasync’s past year of commit activity
    PHP 237 MIT 7 1 1 Updated Sep 9, 2024
  • server Public

    A fast and easy to use coroutine TCP and UDP server

    phasync/server’s past year of commit activity
    PHP 0 0 0 0 Updated Jul 13, 2024
  • swerve Public

    SWERVE - the PHP application server

    phasync/swerve’s past year of commit activity
    PHP 11 0 0 0 Updated Jul 13, 2024
  • http-client Public

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

    phasync/http-client’s past year of commit activity
    PHP 8 MIT 0 0 0 Updated Jun 25, 2024
  • fastcgi-protocol Public

    A class for efficiently parsing and generating FastCGI records.

    phasync/fastcgi-protocol’s past year of commit activity
    0 0 0 0 Updated Jun 11, 2024
  • objectpool Public

    A library for implementing efficient object pooling.

    phasync/objectpool’s past year of commit activity
    PHP 1 0 0 0 Updated Jun 11, 2024
  • file-streamwrapper Public

    Make file IO transparently asynchronous inside phasync PHP coroutines

    phasync/file-streamwrapper’s past year of commit activity
    PHP 5 0 1 0 Updated Jun 9, 2024
  • .github Public
    phasync/.github’s past year of commit activity
    0 0 0 0 Updated May 23, 2024
  • http-streamwrapper Public

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

    phasync/http-streamwrapper’s past year of commit activity
    PHP 1 0 0 0 Updated May 18, 2024

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…