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

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

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

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay