wegar/validate 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wegar/validate

最新稳定版本:v1.0.8

Composer 安装命令:

composer require wegar/validate

包简介

Webman plugin wegar/validate

README 文档

README

通过注解来限制路由的请求方式,如未设置则自由访问;
如设置 app.force = true 则强制所有路由使用注解才能被访问 如设置 app.throw = false 则响应的的是 404

基本使用

Example

<?php

use Wegar\Validate\Annotation\Method\GET;

class ExampleController {
    /**
     * POST /example/index => Method not allowed or 404
     * GET /example/index => Hello World!
     */
    #[GET]
    function index(){
        return response('Hello World!');        
    }
    /**
     * POST /example/page => Hello Page!
     * GET /example/page => Hello Page!
     * ...
     * 
     * if app.force = true
     * POST /example/page => Method not allowed
     * GET /example/page => Method not allowed
     * ...
     * 
     * if app.force = true and app.throw=false
     * POST /example/page => 404
     * GET /example/page => 404
     * ...
     */
    function page(){
        return response('Hello Page!');
    }
}

输入校验

POST/PUT/PATCH方法body优先级高于query,其他方法query优先级高于body

Example

<?php

use Wegar\Validate\Annotation\Method\GET;

class ExampleController {
    #[GET(
      'field' => 'required:msg->Field is required',
      'field2' => 'max:10',
    )]
    function index(){
        return response('Hello World!');        
    }
}

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-13