Participate in Swoft

The Swoft open source framework, a non-commercial project developed and maintained by open source organizations, means that anyone can contribute to their development and progress. There are many ways to participate in Swoft:

  • Code contribution
  • Document contribution
  • Official website maintenance
  • Community maintenance

Code contribution

  1. Fork component code library swoft-component
  2. Send a Pull Request to modify the request
  3. Waiting for the Sofft development team to review and merge

All officially maintained components are consolidated and distributed to each component by the swoft-component project.

Is it difficult to participate in the development of swoft?

Answer this question by comparing swowt with the traditional framework:

  • Frame positioning
    • Traditional framework: Suitable for developing "Bigstone applications", all functions are included in the same code base, suitable for start-up teams to quickly prototype
    • Swoft: Committed to the implementation of micro-services under PHP, the functions are provided by "components", which can be loaded and assembled according to actual needs.
  • Development difficulty
    • Traditional framework
      • Familiar with the classic lnmp system, only consider PHP syntax
      • It is usually necessary to fully understand the entire framework before it can participate in the development. The old framework may take a long time to process the PR.
    • Swoft
      • Familiar with the basics of swoole and network programming, you can easily write concurrency with PHP far beyond fpm
      • The development team provides development guides, component descriptions, and quick response. Developers can choose a simple component to get started and quickly complete a PR.

Difficult? I don't have him, only the hand is well.

Development steps

Using docker

It is recommended to use docker to solve the development environment. The development team maintains two images of swowt/swoft and swowt/alphp . Simple example:

  • Service orchestration using docker-compose
 version: '3.1'
services: # 定义服务
    swoft: # 服务的名称
        image: swoft/alphp:cli
            - ../:/data # 挂载本地的源码到容器的 /data 目录下
            - "80:9501" # 映射本地 80 端口到容器 9501 端口
        links: # 其他基础服务也可以用 docker 解决, 用不到可以先去掉
            - redis
            - mysql
            - rabbitmq       
        tty: true # 开启后, 可以使用 exec 进入到容器中 
  • Simple to use
 docker-compose up -d swoft # 启动服务
docker-compose exec swoft # 进入容器中 

Swoft project description

Swoft contains 2 important items:

Change another saying:

  • Participate in swoft , in fact, do the application layer, how to write in the business, refer to the demo in swowt, popularly - 造飞机
  • Participate in swoft-component , in fact, participate in one of the specific / some components, popularly - 造飞机引擎

swoft architecture design, reflected in the components of the realization swoft in:

  • Framework component framework: the core work of the framework, and the components of the framework core
  • Swoft functional components: divided by function, dependent on framework components, can be loaded on demand, common
    • Rpc family bucket: rpc rpc-server rpc-client
    • Cli reference: console

If you just want to 造飞机 , just use the swoft project to raise the PR. If you want to 造飞机引擎 , you need to give the swoft-component PR. The local needs a scaffold similar to the swoft project to verify.

For example: Participate in RPC component development

If you are not familiar with the basic concepts of RPC, refer to the RPC component related documentation.

Create a new empty folder, such as swoft-test, which acts as the swoft project. As a scaffold, load the required components.

  • Basic file required
 ➜  swoft-test tree -L 2
├── app
│   ├── Application.php
│   └── bean.php
├── bin
│   ├── bootstrap.php
│   └── test.php
├── composer.json
├── config 

Yes, just need so much, copy it from swowt

  • Load the swoft component with composer
  "require": {
    "swoft/rpc": "dev-master",
    "swoft/rpc-server": "dev-master",
    "swoft/rpc-client": "dev-master"
  "autoload": {
    "psr-4": {
      "App\\": "app/"
  "minimum-stability": "dev",
  "repositories": {
    "hyperf": {
      "type": "path",
      "url": "../swoft-component/src/*"
    "packagist": {
      "type": "composer",
      "url": ""

This involves the use of composer to load dependent files locally. Unfamiliar can refer to the official documentation composer-repository

Ok, update:

 composer u --no-dev 

After that, you can execute php bin/swoft to test accordingly. If you get an error, add the missing components according to the error.

  • Modify RPC related files

Modify the swoft-component under the swoft-component , it is recommended to communicate with the development team, and develop the paradigm and CI to ensure the development quality and stability of the components.

More knowledge you need to know

  • Docker basics
  • Github how to mention PR. Recommend a good tool, github desktop, there are shortcut keys to quickly improve PR.
  • Composer documentation, component development and production projects vary, composer provides some interesting features to facilitate development of components

It is recommended to use mac + phpstorm + docker to build a complete development environment. There are related issues, welcome to communicate with the development team.