nirvana72/phprest2

There is no license information available for the latest version (1.1.0) of this package.

PhpRest2 是一款纯restful的轻量框架

1.1.0 2023-05-21 05:45 UTC

This package is auto-updated.

Last update: 2024-04-21 07:39:33 UTC


README

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}";
    }
}

使用示列 Example

环境 Requirements

  • PHP >= 8.0

安装 Installation

composer require nirvana72/phpRest2

nginx 配置

server {
    ...

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

    ...
}

apache 配置

开启 mod_rewrite 模块,入口目录(/public) 下添加 .htaccess 文件:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

文档 Document

参数绑定

参数绑定实体类

中间件hook

数据库操作

ORM

文件上传

事件驱动

路由信息

其它 Other

需要php安装 apcu 扩展

QQ: 15279663