PHPackages                             ksfraser/superglobals - 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. ksfraser/superglobals

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

ksfraser/superglobals
=====================

A PHP library for testable superglobal access with SRP design

03PHP

Since Mar 7Pushed 2mo agoCompare

[ Source](https://github.com/ksfraser/Superglobals)[ Packagist](https://packagist.org/packages/ksfraser/superglobals)[ RSS](/packages/ksfraser-superglobals/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Ksfraser/Superglobals
=====================

[](#ksfrasersuperglobals)

A PHP library that provides testable, dependency-injectable access to superglobals (`$_GET`, `$_POST`, `$_FILES`, etc.) following the Single Responsibility Principle.

Installation
------------

[](#installation)

```
composer require ksfraser/superglobals
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Ksfraser\Superglobals\PostParameterProvider;
use Ksfraser\Superglobals\FormSubmission;

// Inject the parameter provider
$parameterProvider = new PostParameterProvider();
$formSubmission = new FormSubmission($parameterProvider);

// Use in your application logic
if ($formSubmission->hasUpload()) {
    $parser = $formSubmission->getParser();
    $bankAccount = $formSubmission->getBankAccount();
    // ... handle upload logic
}
```

### Testing

[](#testing)

The library is designed to be easily testable by injecting mock parameter providers:

```
use Ksfraser\Superglobals\FormSubmission;
use Ksfraser\Superglobals\ParameterProvider;

class MockParameterProvider implements ParameterProvider {
    private $data;

    public function __construct(array $data) {
        $this->data = $data;
    }

    public function get(string $key): ?string {
        return $this->data[$key] ?? null;
    }

    public function has(string $key): bool {
        return isset($this->data[$key]);
    }

    public function all(): array {
        return $this->data;
    }
}

// Test your form handling logic
$form = new FormSubmission(new MockParameterProvider([
    'upload' => '1',
    'parser' => 'QFX',
    'bank_account' => '123'
]));

assert($form->hasUpload() === true);
assert($form->getParser() === 'QFX');
```

Architecture
------------

[](#architecture)

The library follows SOLID principles:

- **Single Responsibility**: Each class has one reason to change
- **Open/Closed**: Classes are open for extension but closed for modification
- **Liskov Substitution**: Implementations can be substituted for the interface
- **Interface Segregation**: Clients depend only on methods they use
- **Dependency Inversion**: High-level modules don't depend on low-level modules

Classes
-------

[](#classes)

### ParameterProvider Interface

[](#parameterprovider-interface)

Abstracts access to parameter arrays (like `$_GET`, `$_POST`).

### PostParameterProvider

[](#postparameterprovider)

Concrete implementation for `$_POST` superglobal.

### GetParameterProvider

[](#getparameterprovider)

Concrete implementation for `$_GET` superglobal.

### FormSubmission

[](#formsubmission)

Handles form submission logic with dependency injection for testability.

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create a feature branch
3. Add tests for new functionality
4. Ensure all tests pass
5. Submit a pull request

License
-------

[](#license)

This project is licensed under the GPL-3.0-or-later License - see the LICENSE file for details.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance58

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8870cc04b29a973eed9ad367a936ab274d744de37ff0c35fa0540a932905271?d=identicon)[ksfraser](/maintainers/ksfraser)

---

Top Contributors

[![ksfraser](https://avatars.githubusercontent.com/u/54461925?v=4)](https://github.com/ksfraser "ksfraser (1 commits)")

### Embed Badge

![Health badge](/badges/ksfraser-superglobals/health.svg)

```
[![Health](https://phpackages.com/badges/ksfraser-superglobals/health.svg)](https://phpackages.com/packages/ksfraser-superglobals)
```

PHPackages © 2026

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