00f100/fcphp-request

此包的最新版本(0.1.1)没有可用的许可证信息。

管理请求的包

安装: 50

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 1

公开问题: 0

类型:package

0.1.1 2018-08-04 19:20 UTC

This package is auto-updated.

Last update: 2024-09-18 06:07:04 UTC


README

管理请求的包

Build Status codecov Total Downloads

如何安装

Composer

$ composer require 00f100/fcphp-request

或在composer.json中添加

{
    "require": {
        "00f100/fcphp-request": "*"
    }
}

如何使用

<?php

use FcPhp\Request\Request;

$request = new Request($_SERVER);

if($request->isConsole()) {
    /*

    Console Request


    $request->console = [
        'path' => $_SERVER['PWD'],
        'script-name' => $_SERVER['SCRIPT_NAME'],
        'home' => $_SERVER['HOME'],
        'lang' => $_SERVER['LANG'],
        'shell' => $_SERVER['SHELL'],
        'user' => $_SERVER['USER'],
        'username' => $_SERVER['USERNAME'],
        'params' => $_SERVER['argv'],
    ];
    */
    // Print: $request->console['path'] => $_SERVER['PWD']
    echo $request->get('path');

} else {
    /*

    Web Request


    $request->http = [
        'path' => $_SERVER['DOCUMENT_ROOT'],
        'script-name' => $_SERVER['SCRIPT_NAME'],
        'ip-client' => $_SERVER['REMOTE_ADDR'],
        'software' => $_SERVER['SERVER_SOFTWARE'],
        'server-name' => $_SERVER['SERVER_NAME'],
        'method' => $_SERVER['REQUEST_METHOD'],
        'host' => $_SERVER['HTTP_HOST'],
        'port' => $_SERVER['SERVER_PORT'],
        'uri' => $_SERVER['REQUEST_URI'],
        'user-agent' => $_SERVER['HTTP_USER_AGENT'],
        'content-type' => $_SERVER['HTTP_CONTENT_TYPE'],
        'query' => [],
        'headers' => [],
    ];
    */
    // Print: $request->http['method'] => $_SERVER['REQUEST_METHOD']
    echo $request->get('method');
}