# XJPHP RESTful **Repository Path**: UtilityClass/XJPHP-RESTful ## Basic Information - **Project Name**: XJPHP RESTful - **Description**: XJPHP RESTful : 是一个超轻量的快速开发框架。Light and Fast。 - **Primary Language**: PHP - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-05-15 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # XJPHP RESTful : 是一个超轻量的快速开发框架。Light and Fast。 # Encode : UTF-8 **特色** - 基于 MVC 体系; - 超轻量级,小巧的框架; - 出色的性能; - 广泛兼容标准主机上的各种 PHP 版本和配置; - 实现简单,快速扩展; - 清晰的应用分层,可以帮助您构建大型的应用; - 支持路由分层,灵活的 URL 路由; - PHP PDO 数据库的支持; **控制器** ``` data = array(); $this->data["id"] = $IDs[0]; $this->data["class"] = __CLASS__; $this->data["page_content"] = "index.php"; } public function Get($IDs){ $this->data["title"] = "Welcome to ".$_ENV['XJ_PHP']; $this->data["id2"] = (isset($IDs[1]))?$IDs[1]:''; $queryData = $this->input->value('queryData'); $this->load->view("index.php", $this->data); } public function Post($IDs){ $data = array(); $data["title"] = "Welcome to XJPHP"; $data["id"] = $IDs[0]; $data["id2"] = (isset($IDs[1]))?$IDs[1]:''; $this->output->append('Hello World!'); } public function Head($IDs){ $data = array(); $data["title"] = "Welcome to XJPHP"; $data["id"] = $IDs[0]; $data["id2"] = (isset($IDs[1]))?$IDs[1]:''; xj_load_view("index.php", $data); } public function Put($IDs){ $data = array(); $data["title"] = "Welcome to XJPHP"; $data["id"] = $IDs[0]; $data["id2"] = (isset($IDs[1]))?$IDs[1]:''; xj_load_view("index.php", $data); } public function Delete($IDs){ $data = array(); $data["title"] = "Welcome to XJPHP"; $data["id"] = $IDs[0]; $data["id2"] = (isset($IDs[1]))?$IDs[1]:''; xj_load_view("index.php", $data); } } ``` **NGINX 配置** ``` server { listen 8088; # 端口 server_name localhost; # 域名 root html_sldy; # 代码目录 location / { index index.php index.html index.htm; #-e和!-e判断是否存在文件或目录, 如果请求既不是一个文件,也不是一个目录,则执行一下重写规则 if (!-e $request_filename) { #地址作为将参数rewrite到index.php上。 rewrite ^/(.*)$ /index.php/$1 last; #若是子目录则使用下面这句,将subdir改成目录名称即可。 #rewrite ^/subdir/(.*)$ /subdir/index.php/$1 last; break; } } location ~ \.php { fastcgi_pass 127.0.0.1:9000; #fastcgi_index index.php; include fastcgi_params; set $fastcgi_script_name2 $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") { set $fastcgi_script_name2 $1; set $path_info $2; } fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2; fastcgi_param SCRIPT_NAME $fastcgi_script_name2; } } ```