peachpear / peach-api
peach for api framework
1.1.0
2022-05-09 09:41 UTC
Requires
- php: ^7.1.0
- peachpear/phpdotenv: ^1.0.0
- yiisoft/yii2: ~2.0.0
Replaces
- bower-asset/inputmask: >=3.2.0
- bower-asset/jquery: >=1.11.0
- bower-asset/punycode: >=1.3.0
- bower-asset/yii2-pjax: >=2.0.0
README
pear让你更畅快地编程。peach-api是以yii2为基础,去除次要服务,重构为只支持api访问服务的框架。 支持PHP、MySQL。
前提准备
必要服务支持:nginx、php-fpm、mysql
可选服务支持:
使用说明
cd /yourProjectParentPath
composer create-project peachpear/peach-api yourProjectName
cd /path/yourProjectName/backend/config
ln -sf dev.php main.php
nginx 配置
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name yourServerName;
root /path/yourProjectName/public;
index index.php;
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri =404;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri =404;
}
location ~* /\. {
deny all;
}
}
目录结构
├── backend
| ├── components
| ├── config
| ├── controllers
| └── lib
├── common
│ ├── components
│ ├── config
│ ├── dao
│ ├── exception
│ ├── lib
│ ├── misc
│ ├── models
│ └── service
└── console
├── components
├── config
└── controllers
编码规范
1.PHP所有 关键字 必须 全部小写(常量 true 、false 和 null 也 必须 全部小写)
2.命名model对应的class 必须 以Model结尾
3.命名service对应的class 必须 以Service结尾
4.命名dao对应的class 必须 以Dao结尾
5.数据库查询返回接口 应该 使用model对象/对象列表
6.数据库的key必须是dbname+DB形式,e.g:dbname为test,则key为testDB
7.dao目录存放sql语句或者orm
8.model目录存放对应的数据实例对象
9.service目录存放业务逻辑处理