PHPackages                             moderntribe/square1-request - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. moderntribe/square1-request

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

moderntribe/square1-request
===========================

A utility for accessing information about the request environment

4.2.3(3y ago)07GPL-2.0-onlyPHPPHP &gt;=7.4

Since Sep 3Pushed 5mo ago18 watchersCompare

[ Source](https://github.com/moderntribe/square1-request)[ Packagist](https://packagist.org/packages/moderntribe/square1-request)[ RSS](/packages/moderntribe-square1-request/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (38)Used By (0)

Request Object
==============

[](#request-object)

Tribe Libs provides a Request helper object in order to allow easy access to common request (or server) related values, such as headers, input values, and URL/path information.

Usage
-----

[](#usage)

This object can be made available to your classes via direct injection in your constructor

```
class My_Cool_Class {

    protected $request;

    public function __construct( Request $request ) {
        $this->request = $request;
    }

}
```

Once injected, the Request object will automatically contain the various values relating to the current request. For instance, to access the `Content-Type` header, you could use:

```
$content_type = $this->request->header('Content-Type');
```

The Request Object is also available via a Facade for usage in classes in which you don't have control over the Constructor (such as a Controller) in order to inject the class as you normally would.

Methods
-------

[](#methods)

### query()

[](#query)

```
@return \WP_Query
```

Get the current `\WP_Query` global object. Note that this always grabs the `global $wp_query` at the time of calling in order to provide the most-up-to-date version of the object, so it can be used just like `global $wp_query` can within hooks.

```
$query = $this->request->query();
$posts = $query->found_posts;
```

### headers()

[](#headers)

```
@return array
```

Get all of the headers for this request.

```
$headers = $this->request->headers();

echo $headers['Content-Type'];
```

### header( $key )

[](#header-key-)

```
@param  string $key
@return string
```

Get the header value by key.

```
$content_type = $this->request->header('Content-Type');
```

### input( $key )

[](#input-key-)

```
@param  string $key
@return mixed
```

Get the input from the Request by key. Automatically detects the method (GET, POST, JSON body) and returns the value from the correct method values.

```
$foobar = $this->request->input('foobar');
```

### all()

[](#all)

```
@return array
```

Get all input values from the Request. Automatically detects method and pulls in the values from there. If method is *not* GET and the request also has query parameters, returns both the method input *and* the query parameters.

```
$all_input = $this->request->all();
```

### only( $keys )

[](#only-keys-)

```
@param  array $keys
@return array
```

Return *only* input values matching the provided keys. Returns an array containing only those keys which existed (including empty values). Will not return values for non-existent keys.

```
$keys = [ 'foo', 'bar', 'bash' ];

$values = $this->request->only( $keys );
```

### except( $keys )

[](#except-keys-)

```
@param  array $keys
@return array
```

Return all input values *except* those matching the provided keys. Returns an empty array if no other values exist beyond the provided keys.

```
$keys = [ 'foo', 'bar' ];

$values = $this->request->except( $keys );
```

### has( $key )

[](#has-key-)

```
@param  string $key
@return bool
```

Determine whether an input matching the provided key exists in the Request. Will return `true` if input key exists even if it is empty.

```
$has_foobar = $this->request->has('foobar');

if ( $has_foobar ) {
    // do thing.
}
```

### filled( $key )

[](#filled-key-)

```
@param  string $key
@return bool
```

Determine whether an input matching the provided key exists and is non-empty. Will return `true` if value is bool or 0, but `false` for any empty string or null value.

```
$foobar_filled = $this->request->filled('foobar');

if ( $foobar_filled ) {
    // do thing.
}
```

### path( $include\_params = false )

[](#path-include_params--false-)

```
@param  bool $include_params
@return string
```

Get the current Request path. If `$include_params` is set to `true`, also include any Query Params in the path.

```
// URL is http://foobar.com/page/here?foo=bar

$path = $this->request->path();
echo $path;

// /page/here

$path_with_params = $this->request->path( true );
echo $path_with_params;

// /page/here?foo=bar
```

### url()

[](#url)

```
@return string
```

Get the current Request URL. Does not contain path or any Query Parameters.

```
// URL is http://foobar.com/page/here?foo=bar

$url = $this->request->url();
echo $url;

// http://foobar.com
```

### full\_url()

[](#full_url)

```
@return string
```

Get the full current Request URL. Includes both the path and any Query Parameters.

```
// is http://foobar.com/page/here?foo=bar

$full_url = $this->request->full_url();
echo $full_url;

// http://foobar.com/page/here?foo=bar
```

### is( $path )

[](#is-path-)

```
@param  string $path
@return bool
```

Determine if the current Request Path matches the given pattern. Wildcards (\*) can be used.

```
// URL is http://foobar.com/page/here?foo=bar

$is_page = $this->request->is('page/here');

// true

$is_page = $this->request->is('page/*');

// true

$is_page = $this->request->is('page');

// false
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance48

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Recently: every ~1 days

Total

37

Last Release

1366d ago

Major Versions

3.6.0 → 4.0.82022-08-17

PHP version history (2 changes)v3.2.0PHP ^7.2

4.0.8PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/6aa10556f9e67f0a27a22542d7baab7914c2dae633502bf25fcc877e62bb19c5?d=identicon)[jbrinley](/maintainers/jbrinley)

---

Top Contributors

[![jbrinley](https://avatars.githubusercontent.com/u/288845?v=4)](https://github.com/jbrinley "jbrinley (7 commits)")[![defunctl](https://avatars.githubusercontent.com/u/1066195?v=4)](https://github.com/defunctl "defunctl (5 commits)")[![tr1b0t](https://avatars.githubusercontent.com/u/14128420?v=4)](https://github.com/tr1b0t "tr1b0t (2 commits)")[![dpellenwood](https://avatars.githubusercontent.com/u/1151082?v=4)](https://github.com/dpellenwood "dpellenwood (1 commits)")

### Embed Badge

![Health badge](/badges/moderntribe-square1-request/health.svg)

```
[![Health](https://phpackages.com/badges/moderntribe-square1-request/health.svg)](https://phpackages.com/packages/moderntribe-square1-request)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
