Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
Open Swoole is a high-performance network framework based on an event-driven, asynchronous, non-blocking I/O coroutine programming model for PHP.
Designed for building large scale concurrency systems. It is written in C/C++ and installed as a PHP extension. Enabling PHP developers to write code in a more efficient manner, taking advantage of event-loops and fibers/coroutines.
Providing you with an easy to use coroutine API and allowing you to use existing libraries within the PHP ecosystem.
PHP developers can use Open Swoole to write high-performance, scalable, concurrent TCP, UDP, Unix Socket, HTTP, WebSocket, FastCGI services with PHP syntax. You Don't have to be an expert on non-blocking I/O programming and low-level Linux kernel development to take advantage of what Open Swoole offers.
Compared with other Async programming frameworks or software such as Nginx, Tornado, Node.js, Open Swoole is a complete PHP Async solution that has built-in support for async programming via coroutines, a range of multi-threaded I/O modules (HTTP Server, WebSockets, TaskWorkers, Process Pools) and support for popular PHP clients like PDO for MySQL, Redis and CURL.
With the power and performance Open Swoole brings you can write scalable PHP applications for web servers, API backends, game servers, chat systems, CMS platforms, micro-services and realtime web services etc.
Developers can wite PHP code using a Synchronous or Asynchronous programming model and not have to rely on callback hell because of how Open Swoole achieves concurrency with coroutines, a much easier way to write Asynchronous code in a Synchronous style.
Open Swoole enhances the efficiency of your PHP applications and brings you out of the traditional stateless model, enabling you to focus on the development of innovative products at high scale, brining event loops and asynchronous programming to the PHP language.
Open Swoole follows similar asynchronous principles from Erlang, Node.js and Netty, but for PHP.
The Open Swoole framework is released as a PHP extension (PECL) and runs as a PHP CLI application, you can either run a Open Swoole HTTP server directly on your network or use Apache or Nginx and a proxy pass through to your Open Swoole enabled application.
<?php
use OpenSwoole\Http\Server;
use OpenSwoole\Http\Request;
use OpenSwoole\Http\Response;
$server = new OpenSwoole\HTTP\Server("127.0.0.1", 9501);
$server->on("start", function (Server $server) {
echo "OpenSwoole http server is started at http://127.0.0.1:9501\n";
});
$server->on("request", function (Request $request, Response $response) {
$response->header("Content-Type", "text/plain");
$response->end("Hello World\n");
});
$server->start();
Interested with Open Swoole? Get Started with Open Swoole now!
You can also check the Open Swoole Error Codes.
Have more questions or need support? - Checkout the community page or the Open Swoole Quick Start guide. We even have a Support Service as well.