PhpRest2 是一款纯restful的轻量框架, 基于php8及以上版本
<?php
namespace App\Controller;
use PhpRest2\Controller\Attribute\{Controller, Action};
#[Controller('/index')]
class IndexController
{
#[Action('GET:/index')]
public function index($p1)
{
return "p1 = {$p1}";
}
}
- PHP >= 8.0
composer require nirvana72/phpRest2
server {
...
location / {
try_files $uri /index.php$is_args$args;
}
...
}
开启 mod_rewrite 模块,入口目录(/public) 下添加 .htaccess 文件:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
需要php安装 apcu 扩展
QQ: 15279663