Is it possible to install swoole in windows machine?
Asked Answered
H

4

8

I have installed Laravel 5 with php7 and which is working perfectly on my Windows machine. Recently I came to know that SWOOLE is a promising tool for PHP developers!

Unfortunately, I couldn't find any SWOOLE installers for windows.

Isn't it possible to install SWOOLE on a Windows machine, if so how?

Thanks in advance.

Hamadryad answered 1/7, 2018 at 11:37 Comment(2)
Not.it is supported only for linux osTryma
@SalmanZafar if it is an answer don't comment just add a new answerHalfbound
T
3

No.For now swoole is only supported for linux and Mac.

Tryma answered 1/7, 2018 at 20:37 Comment(2)
How about on Windows Subsystem for Linux?Carton
@AttilaSzeremi may be this link can help you. codeblogbt.com/archives/152301Tryma
T
5

Not directly, but with Docker and WSL (Windows Subsystem for Linux).

  1. Install Docker (https://www.docker.com/products/docker-desktop)
  2. Setup WSL

Open PowerShell as Administrator and run

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Updating/Install the WSL 2 Linux kernel (https://learn.microsoft.com/en-us/windows/wsl/wsl2-kernel)

  1. Enable "Enable the experimental WSL 2 based engine" in Docker (General)
  2. Build the Docker container

IMPORTANT! Don't use a path with spacebars like:

  • C:\Users\ {FIRSTNAME}[SPACEBAR]{LASTNAME}\Desktop\docker)

Create a folder (D:\docker) and create with an Editor the Dockerfile (D:\docker\Dockerfile)

FROM php:7.4.2-cli

RUN apt-get update && apt-get install vim -y && \
    apt-get install openssl -y && \
    apt-get install libssl-dev -y && \
    apt-get install wget -y && \
    apt-get install git -y && \
    apt-get install procps -y && \
    apt-get install htop -y

RUN cd /tmp && git clone https://github.com/swoole/swoole-src.git && \
    cd swoole-src && \
    git checkout v4.4.15 && \
    phpize  && \
    ./configure  --enable-openssl && \
    make && make install

RUN touch /usr/local/etc/php/conf.d/swoole.ini && \
    echo 'extension=swoole.so' > /usr/local/etc/php/conf.d/swoole.ini

RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64
RUN chmod +x /usr/local/bin/dumb-init

RUN apt-get autoremove -y && rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["/usr/local/bin/dumb-init", "--", "php"]

Open PowerShell navigate to your folder (D:\docker) to build the DockerImage

docker build -f ./Dockerfile -t swoole-php .
  1. Add your swoole source code

As an example (D:\docker\server.php)

<?php
$http = new Swoole\HTTP\Server("0.0.0.0", 9501);

$http->on('start', function ($server) {
    echo "Swoole http server is started at http://127.0.0.1:9501\n";
});

$http->on('request', function ($request, $response) {
    $response->header("Content-Type", "text/plain");
    $response->end("Hello World\n");
});

$http->start();
?>
  1. Start your swoole http server with the PowerShell
docker run --rm -p 9501:9501 -v D:/docker/:/app -w /app swoole-php server.php
Thereby answered 26/4, 2020 at 1:48 Comment(0)
M
4

I think you are looking for Cygwin and a tutorial how to use it with Swoole

UPDATE June 2020

you can also use Microsoft Windows Subsystem for Linux (WSL)

Miki answered 22/2, 2020 at 22:46 Comment(0)
T
3

No.For now swoole is only supported for linux and Mac.

Tryma answered 1/7, 2018 at 20:37 Comment(2)
How about on Windows Subsystem for Linux?Carton
@AttilaSzeremi may be this link can help you. codeblogbt.com/archives/152301Tryma
I
1

For now, swool is only supported for Linux and Mac.but use Cygwin

follow this link

Isochronous answered 21/3, 2020 at 16:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.