ITPub博客

首页 > IT职业 > IT图书 > Request.php-1

Request.php-1

IT图书 作者:summo 时间:2021-09-09 09:16:07 0 删除 编辑

 

namespace IlluminateHttp;

 

use Closure;

use ArrayAccess;

use SplFileInfo;

use RuntimeException;

use IlluminateSupportArr;

use IlluminateSupportStr;

use IlluminateSupportTraitsMacroable;

use IlluminateContractsSupportArrayable;

use SymfonyComponentHttpFoundationParameterBag;

use SymfonyComponentHttpFoundationRequest as SymfonyRequest;

// long namespace

class Request extends SymfonyRequest implements Arrayable, ArrayAccess

{// Request

    use Macroable;// use trait

 

   

    protected $json;// The decoded JSON content for the request.

 

   

    protected $convertedFiles;//converted file

 

   

    protected $userResolver;//The user resolver callback.

 

   

    protected $routeResolver;// The route resolver callback.

 

   

    public static function capture()

    {

        static::enableHttpMethodParameterOverride();// static::

 

        return static::createFromBase(SymfonyRequest::createFromGlobals());

    }// Create a new Illuminate HTTP request from server variables.

 

   

    public function instance()

    {

        return $this;

    }//Return the Request instance

 

   

    public function method()

    {

        return $this->getMethod();

    }// get the request method.

 

   

    public function root()

    {

        return rtrim($this->getSchemeAndHttpHost().$this->getBaseUrl(), '/');

    }// Get the root URL for the application.

 

   

    public function url()

    {

        return rtrim(preg_replace('/?.*/', '', $this->getUri()), '/');

    }// Get the URL (no query string) for the request.

 

   

    public function fullUrl()

    {

        $query = $this->getQueryString();// query ,get Query String

 

        $question = $this->getBaseUrl().$this->getPathInfo() == '/' ? '/?' : '?';// question

 

        return $query ? $this->url().$question.$query : $this->url();// query

    }// Get the full URL for the request.

 

   

    public function path()

    {

        $pattern = trim($this->getPathInfo(), '/');

 

        return $pattern == '' ? '/' : $pattern;

    }//get Path

 

   

    public function decodedPath()

    {

        return rawurldecode($this->path());

    }//decode Path get the path

 

   

    public function segment($index, $default = null)

    {

        return Arr::get($this->segments(), $index - 1, $default);

    }//Get a segment from the URI (1 based index).

 

   

    public function segments()

    {

        $segments = explode('/', $this->path());

 

        return array_values(array_filter($segments, function ($v) {

            return $v != '';

        }));// array_values.

    }// Get all of the segments for the request path

 

   

    public function is()

    {

        foreach (func_get_args() as $pattern) {

            if (Str::is($pattern, urldecode($this->path()))) {

                return true;

            }

        }

 

        return false;

    }// check current request.


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/225/viewspace-2801561/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-07-23

  • 博文量
    0
  • 访问量
    929