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.
Not directly, but with Docker and WSL (Windows Subsystem for Linux).
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)
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 .
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();
?>
docker run --rm -p 9501:9501 -v D:/docker/:/app -w /app swoole-php server.php
No.For now swoole is only supported for linux and Mac.
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)
For now, swool is only supported for Linux and Mac.but use Cygwin
follow this link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With