sn01615 / ssf
此包已被 废弃 且不再维护。未建议替代包。
简单的 swoole 框架
v0.0.3
2020-12-21 19:15 UTC
Requires
- php: ^7.1
- ext-json: *
- ext-pdo: *
- filp/whoops: ^2.9
- illuminate/database: ^5.8
- illuminate/events: ^5.8
- nikic/fast-route: ^1.3
- symfony/dotenv: ^4.4
- symfony/http-foundation: ^4.4
- twig/twig: ^2.13
Requires (Dev)
- swoole/ide-helper: ^4.5
README
简单的 swoole 框架
安装
composer create-project sn01615/ssf yourname dev-main
运行
php index.php
Nginx 配置
server {
...
location / {
try_files $uri /sw_proxy_pass;
}
location /sw_proxy_pass {
proxy_http_version 1.1;
proxy_set_header Connection "keep-alive";
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:9501$request_uri;
}
...
}
数据库:查询构建器
Model 的 mtb 和 tb 属性都是 Illuminate\Database\Eloquent\Builder 实例,不同的是 mtb 使用主库,tb 可能查询从库
查询数据
$result = $this->mtb->where('id', $id)->limit(1)->get()->toArray();
直接运行 SQL(使用 db 属性的 select 等方法)
$result = $this->db->select("select * from user where id = 1 limit 1");
插入数据可以使用 iInsert 方法
$newId = $this->iInsert([ 'name' => 123, ]);
更新数据
$affected = $this->mtb->where('id', 1)->update([ 'name' => '哈哈', ]);
Model 命名说明 TestModel 会映射到 test 表 UserModel 会映射到 user 表 XxCccModel 会映射到 xx_ccc 表,驼峰命名会转成下划线
参考
数据库 Laravel 数据库语法参考 https://laravel.net.cn/docs/5.8/database
模板引擎 Twig 语法参考 https://twig.symfony.com.cn/doc/2.x
使用交流
群号:21890295