Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

swoole/swoole-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Swoole Docs

Swoole is an high-performance network framework using an event-driven, asynchronous, non-blocking I/O model which makes it scalable and efficient. It is written in C language without 3rd party libraries as PHP extension.

It enables PHP developers to write high-performance, scalable, concurrent TCP, UDP, Unix Socket, HTTP, WebSocket services in PHP programming language without too much knowledge about non-blocking I/O programming and low-level Linux kernel.

Compared with other async programming frameworks or softwares such as Nginx, Tornado, Node.js, Swoole has the built-in async, multiple threads I/O modules. Developers can use sync or async API to write the applications.

Swoole PHP network framework enhances the efficiency of R&D team, enable them to focus on the development of innovative products.

Swoole follows the same principle as Node.js and Netty, but for PHP.

The Swoole framework is released as a PHP extension (PECL) and runs as a PHP CLI application.

Hello world

<?php
$http = new swoole_http_server("127.0.0.1", 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();

Features

  • Rapid development of high performance protocol servers & clients with PHP language
  • Event-driven, asynchronous programming for PHP
  • Event loop API
  • Processes management API
  • Memory management API
  • Async TCP/UDP/HTTP/WebSocket/HTTP2 client/server side API
  • Async TCP/UDP client side API
  • Async MySQL client side API and connection pool
  • Async Redis client/server side API
  • Async DNS client side API
  • Message Queue API
  • Async Task API
  • Milliseconds scheduler
  • Async File I/O API
  • Golang style channels for inter-processes communication
  • System locks API: Filelock, Readwrite lock, semaphore, Mutex, spinlock
  • IPv4/IPv6/UnixSocket/TCP/UDP and SSL/TLS support
  • Fast serializer/unserializer

Use cases

  • Web applications and systems
  • Mobile communication systems
  • Online game systems
  • Internet of things
  • Car networking
  • Smart home systems

Swoole framework is open source and free. Released under the license of Apache 2.0.

Environment preparation for swoole.

The installation guide of swoole.

Try the examples of swoole.

Swoole server provides the API to write TCP / UDP / UnixSocket servers.

Swoole HTTP server provides the API to write HTTP servers.

Swoole WebSocket server provides the API to write WebSocket servers.

Swoole Redis server provides the API to write TCP servers with Redis protocol.

Swoole client provides the API to write TCP/UDP/UnixSocket/HTTP clients, supports IPv4/IPv6 protocol. Developers can write sync or async client side features with swoole client API.

Linux process management module can be used to create new Linux process, manage the processes, and the communication between different processes.

Async API includes the async File IO API, Timer, async HTTP client API, async MySQL client API, async Redis client API and async DNS client API.

The swoole async MySQL client is a replacement of the other sync MySQL clients: libmysqlclient, mysqlnd, mysqli.

Swoole async Redis client is based on hiredis.

Swoole Async HTTP client is a high performance and async HTTP client supports Http-Chun, Keep-Alive, form-data.

Http2.0 client support stream and multiplexing. Multiple GET or POST request can be sent over the same TCP connection.

Developers can use Swoole EventLoop API to use the system EventLoop.

Schedule functions to run at set intervals, accurate to milliseconds.

Integer variable allows any processor to atomically test and modify. Implemented based on CPU atomic instructions.

The memory management module enables developers managing memory like C language without worrying about memory allocation, release.

Swoole table is a high performance memory management module, implemented based on shared memory and spin lock.

Swoole provides the API to use mmap for files access.

Fast serialization for PHP.

Memory data structure likes Chan in Golang, implemented based on shared memory and Mutex locks. It can be used as high-performance message queue in memory.

Swoole locks enable PHP developers to use locks for data synchronisation between multiple threads or processes.

Copyright Β© 2017 BAOKUN DOU & Swoole Development Group, all rights reserved.

Releases

No releases published

Packages

No packages published