Skip to content

Commit 634e540

Browse files
committed
update Docs.
1 parent 5592a70 commit 634e540

File tree

20 files changed

+442
-0
lines changed

20 files changed

+442
-0
lines changed

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
dist
5+
scripts/docsearch-scraper
6+
yarn.lock
7+
8+
# local env files
9+
.env.local
10+
.env.*.local
11+
12+
# Log files
13+
npm-debug.log*
14+
yarn-debug.log*
15+
yarn-error.log*
16+
17+
# Editor directories and files
18+
.idea
19+
.vscode
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
semi: false
2+
singleQuote: true
3+
printWidth: 80

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# PHP-Sword 框架文档
2+

docs/.vitepress/config.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const base = process.env.BASE || '/'
2+
const nav = require('./configs/nav')
3+
const sidebar = require('./configs/sidebar')
4+
5+
module.exports = {
6+
title: 'PHP-Sword Doc',
7+
description: '基于EasySwoole的PHP协程快速开发框架,让你更专注于业务代码的开发!',
8+
head: [
9+
['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }]
10+
],
11+
base: base,
12+
themeConfig: {
13+
repo: 'php-sword/sword',
14+
logo: '/logo.svg',
15+
docsDir: 'docs',
16+
docsBranch: 'master',
17+
18+
// algolia: {
19+
// appId: 'AH43I9TC8T',
20+
// apiKey: '5a2e97575ed3aaa188be999ec7d94f20',
21+
// indexName: 'sword-doc'
22+
// },
23+
24+
// nav
25+
nav,
26+
27+
// sidebar
28+
sidebar,
29+
30+
// page meta
31+
editLinks: false,
32+
editLinkText: '在 GitHub 上编辑此页',
33+
lastUpdated: '上次更新',
34+
},
35+
markdown: {
36+
// options for markdown-it-anchor
37+
anchor: { permalink: false },
38+
39+
// options for markdown-it-toc
40+
toc: { includeLevel: [1, 2] },
41+
42+
config: (md) => {
43+
const { demoBlockPlugin } = require('vitepress-theme-demoblock')
44+
md.use(demoBlockPlugin)
45+
}
46+
}
47+
}

docs/.vitepress/configs/nav.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
module.exports = [
3+
{ text: '文档', link: '/doc/' },
4+
{ text: '组件', link: '/components/'},
5+
// { text: 'API 参考', link: '/api/' },
6+
// {
7+
// text: '外链地址',
8+
// link:
9+
// 'https://web.com'
10+
// }
11+
]

docs/.vitepress/configs/sidebar.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
const sidebar = {
3+
'doc': [
4+
{
5+
text: '项目介绍',
6+
children: [
7+
{
8+
text: '项目介绍',
9+
link: '/doc/index'
10+
},
11+
{
12+
text: '快速开始',
13+
link: '/doc/quick-start'
14+
}
15+
]
16+
},
17+
{
18+
text: '服务搭建',
19+
children: [
20+
{
21+
text: 'HTTP Server',
22+
link: '/doc/service/http-server'
23+
},
24+
{
25+
text: 'WebSocket',
26+
link: '/doc/service/web-socket'
27+
},
28+
{
29+
text: 'TCP/UDP',
30+
link: '/doc/service/tcp-udp'
31+
}
32+
]
33+
}
34+
],
35+
'components': [
36+
{
37+
text: '组件',
38+
children: [
39+
{
40+
text: '基础组件',
41+
link: '/components/index'
42+
}
43+
]
44+
}
45+
]
46+
}
47+
48+
module.exports = {
49+
['/doc/']: sidebar['doc'],
50+
['/components/']: sidebar['components'],
51+
// [getPath('/api/')]: 'auto'
52+
}

docs/.vitepress/theme/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import theme from 'vitepress/dist/client/theme-default'
2+
import 'vitepress-theme-demoblock/theme/styles/index.css'
3+
import { registerComponents } from './register-components'
4+
import Button from '../../../src/components/Button.vue'
5+
import '../../../src/styles/index.css'
6+
import './styles/index.css'
7+
8+
export default {
9+
...theme,
10+
enhanceApp({ app, router, siteData }) {
11+
// app is the Vue 3 app instance from createApp()
12+
// router is VitePress' custom router (see `lib/app/router.js`)
13+
// siteData is a ref of current site-level metadata.
14+
app.component(Button.name, Button)
15+
registerComponents(app)
16+
}
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
import Demo from 'vitepress-theme-demoblock/components/Demo.vue'
3+
import DemoBlock from 'vitepress-theme-demoblock/components/DemoBlock.vue'
4+
export function registerComponents(app) {
5+
app.component('Demo', Demo)
6+
app.component('DemoBlock', DemoBlock)
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
:root {
2+
--c-brand: #646cff;
3+
--c-brand-light: #747bff;
4+
}
5+
6+
.demo-block .xl-button {
7+
margin: 0 10px 10px 0;
8+
}

docs/components/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 组件
2+
3+
组件文档

docs/doc/index.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# PHP-Sword
2+
3+
[![Latest Stable Version](https://poser.pugx.org/php-sword/sword/v)](https://packagist.org/packages/php-sword/sword)
4+
[![Total Downloads](https://poser.pugx.org/php-sword/sword/downloads)](https://packagist.org/packages/php-sword/sword)
5+
[![PHP Version](https://img.shields.io/badge/php-%3E%3D7.3-8892BF.svg)](https://www.php.net/)
6+
[![License](https://poser.pugx.org/php-sword/sword/license)](https://packagist.org/packages/php-sword/sword)
7+
8+
```
9+
_____ _
10+
/ ____| | | PHP v7.4.21
11+
| (_____ _____ _ __ __| | Swoole v4.7.1
12+
\___ \ \ /\ / / _ \| '__/ _` | Temp Dir /www/dev/Temp
13+
____) \ V V | (_) | | | (_| | Log Dir /www/dev/Temp/Log
14+
|_____/ \_/\_/ \___/|_| \__,_| Based EasySwoole v3.4.6
15+
------------------------v0.1.12------------------------
16+
```
17+
> 基于EasySwoole的PHP协程快速开发框架,让你更专注于业务代码的开发
18+
19+
## 主要特性
20+
21+
* 采用`PHP7`强类型(严格模式)
22+
* 基于Swoole常驻内存
23+
* 更快速的上手Swoole开发
24+
* 清晰的项目结构
25+
* 提供更多便捷的工具
26+
* 更优的静态资源处理
27+
28+
## 安装
29+
- 安装Swoole扩展,已安装的跳过此步骤
30+
31+
访问swoole官网文档
32+
[wiki.swoole.com](https://wiki.swoole.com/#/environment)
33+
根据文档进行操作
34+
35+
- 安装Composer,已安装的跳过此步骤
36+
37+
通过如下命令下载Composer:
38+
39+
```shell
40+
curl -sS https://getcomposer.org/installer | php
41+
mv composer.phar /usr/local/bin/composer
42+
```
43+
44+
- 项目构建安装:
45+
```shell
46+
composer create-project php-sword/sword sword
47+
```
48+
49+
- 如果已经安装并需要更新,项目根目录执行命令:
50+
```shell
51+
composer update php-sword/framework
52+
```
53+
54+
## 启动项目
55+
```shell
56+
php sword server start
57+
```
58+
59+
守护进程(后台运行):
60+
```shell
61+
php sword server start -d
62+
```
63+
64+
停止运行:
65+
```shell
66+
php sword server stop
67+
```
68+
69+
更多详细文档: [http://sword.kyour.cn/doc](http://sword.kyour.cn/doc)
70+
71+
## 项目结构
72+
```
73+
PATH 部署目录
74+
├─App 应用目录
75+
│ ├─HttpController Http控制器
76+
│ ├─WebSocket WebSocket控制器
77+
│ ├─Crontab 定时任务
78+
│ ├─Process 自定义进程
79+
│ ├─Common 公共方法类
80+
│ ├─Model ORM模型
81+
│ └─helper.php 全局公共函数
82+
├─Config 配置文件目录
83+
│ ├─app.php 应用配置
84+
│ ├─database.php 数据库配置
85+
│ ├─redis.php redis服务配置
86+
│ ├─session.php session配置
87+
│ ├─view.php 视图渲染配置
88+
│ └─xxx.php 更多自定义配置
89+
├─Public Web静态资源目录
90+
├─Temp 临时数据、缓存、日志
91+
├─vendor Composer包
92+
├─bootstrap.php bootstrap事件
93+
├─composer.json Composer包配置信息
94+
├─dev.php Easyswoole配置信息
95+
├─EasySwooleEvent.php Easyswoole事件
96+
├─nginx_make.php Nginx配置生成工具
97+
└─sword 命令行入口
98+
```
99+
100+
## 更新记录
101+
102+
[转到文档查看](https://github.com/php-sword/sword/wiki/Update)
103+
104+
## 参与开发
105+
106+
> 直接提交PR或者Issue即可
107+
108+
## 版权信息
109+
110+
本项目遵循Apache2.0 开源协议发布,并提供免费使用。
111+
112+
本项目包含的第三方源码和二进制文件之版权信息另行标注。

docs/doc/quick-start.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 环境要求
2+
3+
满足基本的环境要求才能运行框架,EasySwoole 框架对环境的要求十分简单,只需要满足运行 Swoole 扩展的条件,并且 PHP 版本在 7.3 以上即可
4+
5+
## 基础运行环境

docs/doc/service/http-server.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Http控制器
2+
3+
控制器层是负责处理客户端请求,转发给响应模型,并将结果返回给客户端。
4+
5+
这和其他框架类似,通过创建控制器类,底层会将请求解析到对应的控制器方法去处理请求。
6+
7+
> 在App/HttpController 目录新建 `Index.php`
8+
9+
```php
10+
<?php
11+
namespace App\HttpController;
12+
13+
class Index extends BaseController
14+
{
15+
public function index()
16+
{
17+
//直接输出
18+
$this->response()->write('hello php-sword!');
19+
}
20+
}
21+
```

docs/doc/service/tcp-udp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## TCP/DUP 服务器

docs/doc/service/web-socket.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## WEBSOCKET 服务器

docs/index.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
home: true
3+
heroImage: /logo.svg
4+
actionText: 开始使用
5+
actionLink: /doc/
6+
7+
altActionText: Learn More
8+
altActionLink: /doc/
9+
10+
features:
11+
- title: 💡 高性能
12+
details: 全协程异步实现,性能远超所有传统 PHP-FPM 框架!
13+
- title: ⚡️ 快速启动
14+
details: 自动按需加载,秒启动,常驻内存,性能提升数倍!
15+
- title: 🛠️ 简单高效
16+
details: 清晰的项目架构,只需简单的操作就可以跑起来!
17+
- title: 📦 组件丰富
18+
details: 全组件化设计,超多常用组件,绝大部分组件均可复用于其它框架!
19+
- title: 🔩 严格模式
20+
details: 采用`PHP7`强类型(严格模式),遵循更多的PSR规范。
21+
- title: 🔑 更多的示例代码
22+
details: 提供非常多的示例代码,开箱即用。
23+
footer: 蜀ICP备20006619号-1 | Copyright © 2021-present Kyour.cn
24+
---

docs/public/logo.svg

Lines changed: 15 additions & 0 deletions
Loading

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "sword-doc",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"scripts": {
7+
"docs:dev": "vitepress dev docs",
8+
"docs:build": "vitepress build docs",
9+
"docs:serve": "vitepress serve docs"
10+
},
11+
"dependencies": {},
12+
"devDependencies": {
13+
"vue": "^3.2.11",
14+
"prettier": "^2.4.0",
15+
"vitepress": "^0.17.3",
16+
"vitepress-theme-demoblock": "^1.1.1"
17+
}
18+
}

0 commit comments

Comments
 (0)