Install Swoft

Docker installation (recommended)

 docker run -p 18306:18306 --name swoft swoft/swoft  

Docker-Compose installation (recommended)

 git clone
cd swoft
docker-compose up 


  • docker-compose up after the start, the default startup http server, and it is the first process container ( pid=1 ), therefore there is no way to enter the container stop / restart the server

If you want to enter the container after booting, manually manage the startup of the swoft server. You need to adjust the docker-compose.yml slightly:

    image: swoft/swoft
#    for local develop
    command: php -S 

Add a commad command to override the default startup server command. After booting, enter the container and manually start the server php bin/swoft http:start .

At this point, the server process is not the first process of the container, you can use the other commands of the swowt server to stop / restart operations.

  • To test the use of the db function, note that host= needs to be changed to host=mysql:13306

Because the associated db in docker-compose is in another container, you can no longer use the connection.

Composer installation

 composer create-project swoft/swoft swoft 

Accelerate domestic download speeds with Packagist国内镜像 , see Composer configuration

Manual installation

 git clone
cd swoft
composer install --no-dev # 不安装 dev 依赖会更快一些
cp .env.example .env
vim .env # 根据需要调整启动参数 

Use Sofftcli

For the swoftcli tool, check out the swowtcli documentation . Support for quickly creating a clean swowt app from different template projects

 php swoftcli.phar create:app --type full YOUR_APP_NAME
php swoftcli.phar create:app --type ws YOUR_APP_NAME
php swoftcli.phar create:app --type tcp YOUR_APP_NAME