denetorus / sketch-min
具有最小设置的 Sketch php 框架
dev-master
2023-08-29 11:45 UTC
Requires
- ext-json: *
- denetorus/sketch: dev-master@dev
This package is auto-updated.
Last update: 2024-09-29 14:07:38 UTC
README
启动项目
步骤 1
下载文件并将它们放置在磁盘上的一个目录中(例如,这个文件夹命名为 "MyAPI")
步骤 2
使用 composer 更新依赖项
composer update
步骤 3
在根目录中创建 "config" 目录,在 config 目录中创建 2 个文件,填写数据库信息
console.json
{
"routers": {
"default": {
"controller_path": "console",
"router": "router\\RouterConsole",
"path": "console",
"sign": "sign\\SignConsole"
}
},
"props":{
"db_params": {
"dsn": "pgsql:host=localhost;port=5432;dbname=dbname",
"user": "postgres",
"password": "admin"
}
}
}
web.json
{
"routers": {
"default": {
"controller_path": "web",
"router": "router\\RouterWeb",
"sign": "sign\\SignWeb",
"use_status": true,
"sign_in_path": "signin",
"error_path": "error/error_404"
},
"rest": {
"controller_path": "rest",
"router": "router\\RouterRest"
}
},
"props":{
"db_params": {
"dsn": "pgsql:host=localhost;port=5432;dbname=dbname",
"user": "postgres",
"password": "admin"
}
}
}
检查
在这一步,您可以通过终端检查项目。
打开终端(控制台)。转到放置项目文件的目录("MyAPI"),运行命令
php sk test
您应该看到以下消息
test console is execute
如果看到错误
'php' is not recognized as an internal or external command,
operable program or batch file."
您可以使用适合您系统的任何一种方法来修复它。Windows 的方法在这里描述
https://www.codeandtuts.com/php-is-not-recognized-as-an-internal-or-external-command/
步骤 4
在 PHP 服务器中配置 ENTRIES POINT 到目录 "/gate"
(在我们的例子中
如果您使用 Windows Apache:打开 Apache 配置文件 "httpd.conf",在文件中查找参数 "Document Root"。填写参数
DocumentRoot "Path_to_directory/MyAPI/gate"
如果您使用 Linux Apache2:更改 Sites-available 配置文件参数
DocumentRoot "Path_to_directory/MyAPI/gate"
如果您使用 Linux Nginx:更改 Sites-available 配置文件参数
root Path_to_directory/MyAPI/gate
)
检查
-
重启 Apache/Nginx
-
转到链接
http://IP_SITE