Swoole platform – a popular PHP 1 network framework

By category:

        Aug 28, 2018




In recent years, Swoole Platform Framework has taken over as the new best programming solution thanks to its scalability and to the performance boosting capabilities it boasts as a PHP extension.

Swoole represents an event-driven network communication framework for asynchronous and parallel PHP requests, which is aimed at scaling up the performance of web applications.

Based on the C language exclusively, Swoole allows PHP developers to write scalable applications for: Internet, mobile communication, cloud computing, online gaming, without the need to have an in-depth knowledge of non-blocking I/O programming.

Learn more about the Swoole framework and about how you can make use of it on our web hosting platform provider.

What is the Swoole framework about?

Swoole was introduced with one basic idea in mind – to provide efficiency to PHP programmers and give them more time and spance  to focus their efforts on more innovative products web.

Boasts built-in async, multi-threadеd I/O (input/output) modules, which distinguish it from the other async programming frameworks such as Nginx and Node.js.

This allows programmers to create network servers io and to perform database and filesystem operations for the PHP language.

PHP developers can use either sync or async API to write the applications web.

Here is a glimpse of the advantages of the Swoole framework:

  • 100% C-compiled, with extremely powerful performance and efficient;
  • Simple and easy to use, development-efficient;
  • Event-driven, non-blocking asynchronous processing;
  • Supports millions of concurrent TCP connections;
  • Supports asynchronous/synchronous/coroutine;
  • Supports multiprocessing/multi-threading;
  • CPU affinity/daemon process;

And here is a list of the key components, which make truly efficient for application development:

  • IPv4 / IPv6 / Unixsocket network support;
  • Async TCP/UDP server and client;
  • SSL / TLS support;
  • Async HTTP/ WebSocket client;
  • Database connection pooling;
  • Async MySQL client;
  • Async Redis Client;
  • Fast Serializer / Unserializer;
  • Milliseconds task scheduler;

With this wide array of components, can be utilized by a number of applications for mobile communication, cloud computing, microservices, mobile games, and live chat systems, to name a few, which are normally within the capacity of C++ or Java developers.

Currently, is adopted by some of the greatest retail platforms like Alibaba and Baidu.

How does the Swoole framework work?

Runs in CLI mode, which distinguishes it from the common PHP model.

Swoole PHP model

Here are the key differences between Swoole and the traditional PHP model:

  • supports more server-side protocols;
  • supports long-live connections for websocket/TCP/UDP server;
  • creates additional worker processes so as to make use of all available CPU cores;
  • can manage and re-use the status in memory.

How to make use of Swoole on our platform?

The Swoole extension has been readily installed on our web hosting platform and you can enable it with a click for your projects.

In the PHP settings section of the Hepsia Control Panel, just scroll down to the setting at the bottom of the table and click on the pertaining checkbox.

Swoole network framework - enable from Control Panel

Note: The extension is currently supported by the PHP 7 version only, so make sure to switch to any of the supported PHP 7 releases first.

Swoole network framework - only for php 7 versions

Once you have enabled Swoole for your hosting account, you will need to create an instance for your project from the Supervisor section.

In the Supervisor section, just click on the Create Instance button and then specify the path to the script you want to use Swoole for:

Swoole network framework - create supervisor instance

In our example, we are using a websocket server script:

Swoole network framework - websocket server example

Once the instance has been added, you will need to copy the port that has been generated for the instance:

Swoole network framework - supervisor instance port

and paste it into the script file as displayed below:

Swoole network framework - replace port in websocket script

That’s it! Now you will be able to run a websocket server by using the Swoole network framework on our platform.

About Us

We provide cloud based enterprise hosting, server and storage solutions of unmatched quality. Feel free to visit or contact us for any question.

Payment We Accepted

Payment Methods Available