DEV Community

hardyweb
hardyweb

Posted on

Compile PHP Swoole and test Swoole http server

*INSTALL SWOOLE *

apt install php-dev libc-ares-dev libcurl4-openssl-dev
Enter fullscreen mode Exit fullscreen mode
sudo pecl install -D 'enable-sockets="yes" enable-openssl="yes" enable-http2="yes" enable-mysqlnd="yes" enable-swoole-json="yes" enable-swoole-curl="yes" enable-cares="yes"' swoole
Enter fullscreen mode Exit fullscreen mode
echo "extension=swoole.so" > /etc/php/8.1/cli/conf.d/20-swoole.ini
Enter fullscreen mode Exit fullscreen mode

CHECK SWOOLE EXTENSION LOADED

php -m | grep swoole 
Enter fullscreen mode Exit fullscreen mode
php --ri swoole 
Enter fullscreen mode Exit fullscreen mode

TEST SWOOLE

<?php

    $http = new Swoole\Http\Server('0.0.0.0', 9501);

    $http->on("request", function ($request, $response) {
        $response->header("Content-Type", "text/plain");
        $response->end("Hello, Swoole!");
    });

     $http->start();
    ?>
Enter fullscreen mode Exit fullscreen mode
curl localhost:9501
Enter fullscreen mode Exit fullscreen mode

Buy Me A Coffee

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs