Application structure

A complete Swoft app can contain:

  • Console Apps
  • HTTP services (similar to traditional frameworks)
  • WebSocket Services
  • RPC Services

swoft-cloud/swoftThat is, a full application of demo. Of course, it's okay if you just want to use some of the features

Application skeleton

appUnder the class directory in order to avoid some folder names without plural words, resulting in inconsistent naming, all folder names uniformly use the singular

├── app/   ------ 应用代码目录
│   ├── Annotation/   ------- 定义注解相关
│   ├── Aspect/       ------- AOP 切面
│   ├── Bean/         ------- 一些具有独立功能的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
│   ├── 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

Render bytree -L 2 -F --dirsfirst

Component Skeleton Structure

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

src/AutoLoader.phpIs a file that must exist for a component, swoft based on it to determine which directories to scan

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