承接 vertilia/request 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

vertilia/request

Composer 安装命令:

composer require vertilia/request

包简介

Simple library to abstract requests (CLI, HTTP, etc.)

README 文档

README

Simple library to abstract request information and validate user input.

Built on ValidArray, it not only provides access to main request information, but integrates input arguments filtering. This allows for simplified access to validated request parameters as in the example below:

<?php

$request = new \Vertilia\Request\HttpRequest(
    $_SERVER,
    $_GET,
    $_POST,
    $_COOKIE,
    file_get_contents('php://input'),
    [
        'id' => ['filter' => \FILTER_VALIDATE_INT, 'options' => ['min_range' => 1]],
        'name' => \FILTER_DEFAULT,
        'email' => \FILTER_VALIDATE_EMAIL,
        'profile' => ['filter' => \FILTER_VALIDATE_URL, 'flags' => \FILTER_FLAG_HOST_REQUIRED],
    ]
);

print_r($request['id']);
print_r($request['name']);
print_r($request['email']);
print_r($request['profile']);

In the example above, $request is initialised with HTTP request data, defines input argument filters and tries to retrieve them from HTTP headers, cookies, POST and GET parameters. In case of other HTTP method used, it parses php://input based on Content-Type HTTP header. All found arguments are then validated following the given filters.

Input validation guarantees that user data is of specified type. Input arguments not mentionned in filters list are ignored. Arguments that do not match filters are set to false. Missing arguments are set to null.

Employed filtering mechanism is standard php extension since php-5.2.

See PHP Filter extension.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2019-05-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固