Application structure

A complete swowt app can contain:

  • Console application
  • Http service (similar to the traditional framework)
  • Websocket service
  • Rpc service
  • Tcp service

swoft-cloud/swoft is a complete application demo. Of course, if you only want to use some of the features, you can.

Application skeleton

app class directory in order to avoid some of the folder name no plural word, resulting in non-uniform names, folder names all unified singular

 ├── app/   ------ 应用代码目录
│   ├── Annotation/   ------- 定义注解相关
│   ├── Aspect/       ------- AOP 切面
│   ├── Common/       ------- 一些具有独立功能的 class bean
│   ├── Console/      ------- 命令行代码目录
│   │   ├── Command/
│   ├── Exception/      ------ 定义异常类目录
│   │   └── Handler/       ------ 定义异常处理类目录
│   ├── Http/         ------ HTTP 服务代码目录
│   │   ├── Controller/
│   │   └── Middleware/
│   ├── Helper/
│   │   └── Functions.php
│   ├── Listener/     ------ 事件监听器目录
│   ├── Model/        ------ 模型、逻辑等代码目录(这些层并不限定,根据需要使用)
│   │   ├── Dao/
│   │   ├── Data/
│   │   ├── Logic/
│   │   └── Entity/
│   ├── Rpc/          ------ RPC 服务代码目录
│   │   └── Service/
│   │   └── Middleware/
│   ├── WebSocket/     ------ WebSocket 服务代码目录
│   │   ├── Chat/
│   │   ├── Middleware/
│   │   └── ChatModule.php
│   ├── Tcp/          ------ Tcp 服务代码目录
│   │   └── Controller/  ------ Tcp 服务处理控制器目录
│   ├── Application.php -------- 应用类文件继承自swoft核心
│   ├── AutoLoader.php  -------- 项目扫描等信息(应用本身也算是一个组件)
│   └── bean.php
├── bin/
│   ├── bootstrap.php
│   └── swoft   ------ swoft 入口文件
├── config/     ------ 应用配置目录
│   ├── base.php  --- 基础配置
│   └── db.php
├── public/     ------ WEB可访问目录
├── resource/   ------ 应用相关资源目录
│   ├── language/   ------ 语言资源目录  
│   └── view/       ------ 视图资源目录  
├── runtime/    ------ 临时文件目录(日志、上传文件、文件缓存等)
├── test/       ------ 单元测试代码目录
│   └── bootstrap.php
├── composer.json
├── composer.lock
├── phar.build.inc
└── phpunit.xml.dist 

tree -L 2 -F --dirsfirst by tree -L 2 -F --dirsfirst

Component skeleton structure

 ├── src/
│   ├── Annotation/  -------- 组件注解类定义
│   ├── Common/         ------- 一些具有独立功能的 class bean
│   ├── Concern/      ------- abstract, traits classes
│   ├── Contract/     ------- interface classes
│   ├── Exception/
│   ├── Helper/
│   ├── Listener/
│   ├── AutoLoader.php  -------- 组件扫描等信息
├── test/   ------ 单元测试代码目录
│   ├── unit/
│   ├── testing/
│   └── bootstrap.php
├── LICENSE
├── README.md
├── composer.json
└── phpunit.xml 

src/AutoLoader.php is a file that must exist for the component. Swoft determines which directory to scan.

Develop custom components

In version 2.0 you can develop a swewt component very easily. Extended reading development custom components

/docs/2.x/en/quick-start/project-skeleton.html
progress-bar