• Stars
    star
    221
  • Rank 179,773 (Top 4 %)
  • Language
    PHP
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ“š Swoole Library

Swoole Library

Twitter Discord Library Status License

Table of Contents

How to Contribute

Just open new pull requests (and we need unit tests for new features)

Code Requirements

Development

Branches

  • 4.6.x: For Swoole 4.6, which supports PHP 7.2+
  • 4.5.x: For Swoole 4.5, which supports PHP 7.1+

Dockerized Local Development (Compose v2)

First, you need to build the base image:

docker compose build image

Then run the following command to autoload PHP classes/files (no extra Composer packages to be installed):

docker compose run --rm composer install

Secondly, run the next command to start Docker containers:

docker compose up

Alternatively, if you need to rebuild the service(s) and to restart the containers:

docker compose build image --no-cache
docker compose up --force-recreate

Now you can create an app's bash session:

docker compose exec app bash

And run commands inside the container:

composer test

Or you can tell to run it directly:

docker compose exec app composer test

Examples

Once you have Docker containers started (as discussed in previous section), you can use commands like following to run examples under folder examples.

Examples of Database Connection Pool

docker compose exec app php examples/mysqli/base.php
docker compose exec app php examples/pdo/base.php
docker compose exec app php examples/redis/base.php

Examples of FastCGI Calls

There is a fantastic example showing how to use Swoole as a proxy to serve a WordPress website using PHP-FPM. Just open URL http://127.0.0.1 in the browser and check what you see there. Source code of the example can be found here.

Here are some more examples to make FastCGI calls to PHP-FPM:

docker compose exec app php examples/fastcgi/greeter/call.php
docker compose exec app php examples/fastcgi/greeter/client.php
docker compose exec app php examples/fastcgi/proxy/base.php
docker compose exec app php examples/fastcgi/var/client.php

Compatibility Patch (Swoole version <= v4.4.12)

define('SWOOLE_USE_SHORTNAME', true); // or false (it depends on you)

Coding Style Checks and Fixes

To update Composer packages (optional):

docker compose run --rm composer update

To check coding standard violations:

docker compose run --rm composer cs-check

To correct coding standard violations automatically:

docker compose run --rm composer cs-fix

Third Party Libraries

Here are all the third party libraries used in this project:

You can find the licensing information of these third party libraries here.

License

This project follows the Apache 2 license.

More Repositories

1

swoole-src

๐Ÿš€ Coroutine-based concurrency library for PHP
C++
18,406
star
2

phpx

๐Ÿ’— C++ wrapper for Zend API
C++
826
star
3

php-cp

pdo and redis tcp connect proxy
C
639
star
4

docker-swoole

๐Ÿ„ Official Docker Image of Swoole
Dockerfile
499
star
5

ide-helper

๐Ÿ“˜ Swoole IDE Helper
PHP
469
star
6

yasd

Yet Another Swoole Debugger
PHP
356
star
7

swoole-wiki

๐Ÿ“–Swooleๅ…จ้‡Markdownๆ–‡ๆกฃ, Swoole-Doc, Swoole-Wiki
Shell
270
star
8

phpkafka

PHP Kafka client is used in PHP-FPM and Swoole. PHP Kafka client supports 50 APIs, which might be one that supports the most message types ever.
PHP
266
star
9

awesome-swoole

๐Ÿ’Ž A curated list of awesome things related to Swoole.
230
star
10

grpc

๐Ÿ’Ž Grpc client based on Swoole Coroutine
PHP
199
star
11

ext-zookeeper

๐Ÿง‘ Coroutine-based ZooKeeper Client for PHP
C
150
star
12

swoole-cli

SWOOLE-CLI is a php binary distribution composed swoole & php-core & cli & fpm and mostly of common extensions.
C
119
star
13

community-chinese

Swoole ๆๆกˆ
117
star
14

thrift-rpc-server

Thrift RPC Server based on swoole
PHP
115
star
15

auto_reload

Inotify็›‘ๆŽงๆ–‡ไปถๅ˜ๆ›ด่‡ชๅŠจ้‡ๅฏswoole_server
PHP
105
star
16

ext-serialize

the fastest serialize function bound for php7
C
93
star
17

ext-async

Asynchronous callback client
PHP
87
star
18

proxy-server

Full asynchronous proxy server can support over a large number of concurrent.
PHP
84
star
19

debugger

Swoole ่ฟœ็จ‹่ฐƒ่ฏ•ๅ™จ
PHP
79
star
20

ext-postgresql

๐Ÿ˜ Coroutine-based client for PostgreSQL
C++
64
star
21

swoole-docs

๐Ÿ“— Please check the latest version: https://www.swoole.co.uk/docs/
61
star
22

phpy

PHP
43
star
23

zmq

ZeroMQ bindings for Swoole
PHP
37
star
24

dashboard

Vue
22
star
25

php-docker

php docker file
Dockerfile
20
star
26

docs

PHP
10
star
27

benchmark

PHP
9
star
28

make-library

Convert PHP code to C/C++ header file
PHP
6
star
29

documents

2
star
30

swoole.github.io

Swoole's website, docs & blog mainly focused on the english-speaking community.
CSS
2
star
31

v4.4-lts

C++
1
star
32

golang-h2demo

Go
1
star