SlimCustom轻量级RESTFul开发框架

联合创作 · 2023-09-20 05:37

轻量级RESTFul开发框架 SlimCustom 可以帮助你快速编写简单但功能强大的 web 应用和 API。 特色:HTTP 路由,中间件,PSR-7 支持,依赖注入,门面模式,模型自动验证,字段预处理,多进程任务管理...

开始使用

注意:{$变量}需要替换成实际的值,拒绝无脑复制

安装 & 卸载

$SlimCustomFrameworkPath/bin/cmd $application app:make      安装
$SlimCustomFrameworkPath/bin/cmd $application app:remove    卸载

web服务器

PHP built-in server

Run the following command in terminal to start localhost web server, assuming ./public/ is public-accessible directory with index.php file:

php -S localhost:8080 -t $SlimCustomFrameworkPath/public/

Nginx 配置

这是一个例子,在 Nginx 虚拟主机上针对域名 example.com 的配置。它监听80端口上的入境(inbound)HTTP 连接。它假定一个PHP-FPM服务器在端口9000上运行。你需要将 server_name, error_log, access_log, 和 root 这些指令修改成你自己的值。其中 root 指令是你的应用程序公共文件根目录的路径;你的 Slim 应用的 index.php 前端控制器文件应该放在这个目录中。

server {
    listen 80;
    server_name example.com;
    index index.php;
    error_log /path/to/example.error.log;
    access_log /path/to/example.access.log;
    root /path/to/public;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        fastcgi_pass 127.0.0.1:9000;
    }
}

slim文档首页

http://www.slimphp.net/docs/start/web-servers.html

目录结构

框架

/bin/cmd                                        命令入口文件(linux)
/bin/cmd.bat                                    命令入口文件(windows)
/bootstrap/autoload.php                         自动载入
/bootstrap/dependencies.php                     框架依赖
/config/application.php                         暂时不用
/config/configs.php                             默认配置文件
/config/errors.php                              错误配置
/config/validation.php                          自动验证配置
/demo/                                          应用demo
/docs/Api/                                      基于phpDoc2生成的php接口文档
/Libs/Cache/Cache.php                           缓存
/Libs/Console/Console.php                       控制台
/Libs/Console/Daemon.php                        任务管理(支持进程管理)
/Libs/Container/Container.php                   容器
/Libs/Contracts/                                约定
/Libs/Controller/Api.php                        接口控制器
/Libs/Controller/Controller.php                 控制器抽象类
/Libs/Curl/Curl.php                             curl
/Libs/Filesystem/Filesystem.php                 文件
/Libs/Handlers/Error.php                        异常处理
/Libs/Handlers/PhpError.php                     php错误处理
/Libs/Helpers/Facades.php                       助手门面
/Libs/Helpers/Helpers.php                       助手函数
/Libs/Http/Response.php                         响应
/Libs/Model/Query/PdoQuery.php                  PDO查询类
/Libs/Model/Model.php                           数据模型
/Libs/Pageinator/Pageinator.php                 分页
/Libs/Session/Session.php                       session
/Libs/Support/Arr.php                           数组
/Libs/Support/Collection.php                    集合
/Libs/Support/MessageBag.php                    消息包
/Libs/Support/Str.php                           字符串
/Libs/Traits/Macroable.php                      
/Libs/Traits/Single.php                         单例
/Libs/Valication/Validator.php                  验证器
/Libs/App.php                                   应用核心类
/vendor/                                        vendor
/index.php                                      入口文件
/README.MD                                      文档

Demo应用

/bootstrap/routes.php                           路由配置
/configs/configs.php                            配置文件
/Console/Console.php                            应用控制台
/Console/Commands/Hello.php                     命令文件 (hello 命令)
/Controller/                                    控制器
/Controller/Admin                               控制器分组
/Controller/Admin/Index.php                     Admin分组下的Index控制器
/data/logs/                                     日志生成目录
/data/cache/                                    缓存生成目录
/data/daemon/                                   任务进程信息生成目录
/docs/                                          docs
/Middlewares/                                   中间件
/Middlewares/Admin/                             中间件分组
/Middlewares/Admin/Index.php                    Admin分组下的Index中间件
/Models/                                        模型目录
/scripts/                                       脚本目录
/scripts/Demo.php                               Demo任务文件
/tests/                                         测试
/public/                                        开放目录
/public/views/                                  视图目录
/public/index.php                               入口文件
/public/.htaccess                               .htaccess文件
浏览 6
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报