PHPackages                             itaotao/swiftphp-installer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. itaotao/swiftphp-installer

ActiveProject[Framework](/categories/framework)

itaotao/swiftphp-installer
==========================

SwiftPHP Framework Installer

00PHP

Since Apr 3Pushed 2mo agoCompare

[ Source](https://github.com/itaotao/swiftphp-installer)[ Packagist](https://packagist.org/packages/itaotao/swiftphp-installer)[ RSS](/packages/itaotao-swiftphp-installer/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

SwiftPHP 框架使用文档
===============

[](#swiftphp-框架使用文档)

1. 安装脚手架
--------

[](#1-安装脚手架)

### 1.1 系统要求

[](#11-系统要求)

- PHP 7.4 或更高版本
- Composer 包管理器
- Windows/Linux/MacOS 操作系统

### 1.2 安装步骤

[](#12-安装步骤)

1. **克隆或下载** SwiftPHP 脚手架到本地

    ```
    git clone https://github.com/itaotao/swiftphp-installer.git
    cd swiftphp-installer
    ```
2. **安装依赖**

    ```
    composer install
    ```
3. **验证安装**

    ```
    php swiftphp --version
    ```

2. 创建新项目
--------

[](#2-创建新项目)

### 2.1 基本创建命令

[](#21-基本创建命令)

```
# 在当前目录创建项目
php swiftphp new myproject

# 指定目标目录
php swiftphp new myproject --dir /path/to/directory
```

### 2.2 项目初始化

[](#22-项目初始化)

创建项目后，进入项目目录并安装依赖：

```
cd myproject
composer install
```

3. 项目结构
-------

[](#3-项目结构)

```
myproject/
├── app/              # 应用目录
│   ├── controller/   # 控制器
│   ├── model/        # 模型
│   ├── middleware/   # 中间件
│   ├── validate/     # 验证器
│   ├── lang/         # 语言文件
│   └── common.php    # 公共函数
├── config/           # 配置文件
├── public/           # 公共目录
│   └── index.php     # Web 入口
├── route/            # 路由配置
├── runtime/          # 运行时目录
├── vendor/           # 依赖包
├── .env              # 环境配置
├── start.php         # 服务器启动文件
├── start.bat         # Windows 启动脚本
└── composer.json     # Composer 配置

```

4. 核心功能使用
---------

[](#4-核心功能使用)

### 4.1 启动服务器

[](#41-启动服务器)

```
# 方法 1：直接运行
php start.php

# 方法 2：使用 Windows 脚本
start.bat

# 方法 3：使用 Composer 脚本
composer run start
```

服务器默认运行在 `http://localhost:8787`

### 4.2 路由配置

[](#42-路由配置)

编辑 `route/route.php` 文件：

```
