PHPackages                             mirazmac/php-requirements-checker - 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. mirazmac/php-requirements-checker

ActiveLibrary

mirazmac/php-requirements-checker
=================================

A quick library to check the current environment against a set of defined requirements. It supports checking for PHP version, OS, Extensions, PHP INI values, Functions, Classes, Apache Modules and local Files and Folders.

0.3(5mo ago)1312.0k↓45.5%33MITPHPPHP &gt;=5.4CI failing

Since Nov 3Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/MirazMac/php-requirements-checker)[ Packagist](https://packagist.org/packages/mirazmac/php-requirements-checker)[ RSS](/packages/mirazmac-php-requirements-checker/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (3)

[![PHP Requirements Checker](https://camo.githubusercontent.com/10c5638163ca336038f5fc26d57bd7426c959917b738317a7d6c38133d461ad0/68747470733a2f2f692e706f7374696d672e63632f50786848625673592f7063722e706e67)](https://camo.githubusercontent.com/10c5638163ca336038f5fc26d57bd7426c959917b738317a7d6c38133d461ad0/68747470733a2f2f692e706f7374696d672e63632f50786848625673592f7063722e706e67)

PHP Requirements Checker
========================

[](#php-requirements-checker)

A PHP library to check the current environment against a set of defined requirements. Currently it supports checking for PHP version, OS, extensions, php.ini values, functions, classes, apache modules and local files and folders.

### Install via composer

[](#install-via-composer)

```
composer require mirazmac/php-requirements-checker
```

### Manual Install

[](#manual-install)

Download the latest release. Extract and require **src/Checker.php** in your code. But it's highly recommended to use [Composer](http://getcomposer.org).

```
require 'src/Checker.php';
```

Usage
-----

[](#usage)

```
use MirazMac\Requirements\Checker;

$checker = new Checker;

// Define requirements
$checker->requirePhpVersion('>=5.6')
        ->requirePhpExtensions(['ffmpeg', 'mbstring'])
        ->requireFunctions(['random_bytes'])
        ->requireFile('../composer.json', Checker::CHECK_FILE_EXISTS)
        ->requireDirectory('../src', Checker::CHECK_IS_READABLE)
        ->requireIniValues([
            'allow_url_fopen' => true,
            'short_open_tag' => true,
            'memory_limit'  => '>=64M',
        ]);

// Runs the check and returns parsed requirements as an array
// Contains parsed requirements with state of the current values
// and their comparison result
$output = $checker->check();

// Should be called after running check() to see if requirements has met or not
$satisfied = $checker->isSatisfied();

if ($satisfied) {
    echo "Requirements are met.";
} else {
    echo join(', ', $checker->getErrors());
}
```

Supported Requirement Checks
----------------------------

[](#supported-requirement-checks)

Every supported requirements check begins with the word **require**. They return the class instance that means they're chain-able. These are the supported checks:

### requirePhpVersion(string $version);

[](#requirephpversionstring-version)

You can check if current PHP version matches your desired version using this method. The parameter `$version` should be a string containing your desired PHP version. Comparison operators can be prepended at the very beginning of the string.

```
$checker->requirePhpVersion('7.0.0');

// Note the comparison operator
// Supports comparison operators: , =, >=
$checker->requirePhpVersion('>=7.0.0');
```

### requireOS(string $os);

[](#requireosstring-os)

You can check if current OS matches with your desired operating system. The parameter `$os` must have one of the following values: `Checker::OS_UNIX`, `Checker::OS_DOS`

```
$checker->requireOS(Checker::OS_UNIX);
```

### requireIniValues(array $values)

[](#requireinivaluesarray-values)

Use this to validate a set of php.ini config values to compare against your provided values. The parameter `$values` should be an array as key =&gt; value fashion, where the key would contain the php.ini config var and the value should be the desired value. Like `requirePhpVersion();` comparison operators can be prepended at the very beginning of the value. To keep things simple and neat, use `boolean` instead of using `On/1/Off/0` for the check.

```
$checker->requireIniValues([
    // Will check if file_uploads is enabled or not
    // Notice the usage of boolean instead of On/Off/1/0
    'file_uploads' => true,

    // Note the comparison operator > before the desired value
    // This means the library will check if post_max_size is greater than 2M or not
    'post_max_size' => '>2M',

    // Set a value to `NULL` to just skip the check for that value
    // Useful when you don't wanna compare but want to fetch the
    // current value on the parsed requirements array
    'safe_mode'   => null,
]);
```

### requirePhpExtensions(array $extensions)

[](#requirephpextensionsarray-extensions)

To make sure provided extensions are loaded. Parameter `$extenstions` should be an array with the extension names.

```
$checker->requirePhpExtensions([
    'openssl', 'mbstring', 'curl'
]);
```

### requireFunctions(array $functions)

[](#requirefunctionsarray-functions)

To make sure provided functions are loaded. Parameter `$functions` should be an array with the function names.

```
$checker->requireFunctions([
    'apcu_fetch', 'mb_substr', 'curl_init'
]);
```

### requireClasses(array $classes)

[](#requireclassesarray-classes)

To make sure provided classes are loaded. Parameter `$classes` should be an array with the class names (namespaced or global namespace will be used).

```
$checker->requireClasses([
    'PDO', 'finfo', 'stdClass'
]);
```

### requireApacheModules(array $modules)

[](#requireapachemodulesarray-modules)

To make sure provided modules are loaded. Parameter `$modules` should be an array with the module names. NOTE: This check will only run if current server is Apache.

```
$checker->requireApacheModules([
    'mod_rewrite', 'mod_mime'
]);
```

### requireFile(string $path, string $check = self::CHECK\_FILE\_EXISTS)

[](#requirefilestring-path-string-check--selfcheck_file_exists)

To check permissions and existence of certain files and directories. The parameter `$path` should be path to any file or directory. The parameter `$check` is the check name that would be performed on the path. The supported values are:

- `Checker::CHECK_IS_FILE` - Runs `is_file()` on the path.
- `Checker::CHECK_IS_DIR` Runs `is_dir()` on the path.
- `Checker::CHECK_IS_READABLE` Runs `is_readable()` on the path.
- `Checker::CHECK_IS_WRITABLE` Runs `is_writable()` on the path.
- `Checker::CHECK_FILE_EXISTS` Runs `file_exists()` on the path.

NOTE: `requireDirectory()` is an alias of this method.

```
$checker->requireFile('app/config.ini', Checker::CHECK_IS_FILE)
        ->requireFile('app/cache', Checker::CHECK_IS_WRITABLE);
        ->requireDirectory('app/cache', Checker::CHECK_IS_DIR);
```

Todos
-----

[](#todos)

- Write tests
- Write extended docs

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance72

Regular maintenance activity

Popularity32

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 89.5% 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.

###  Release Activity

Cadence

Every ~749 days

Total

3

Last Release

159d ago

### Community

Maintainers

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

---

Top Contributors

[![MirazMac](https://avatars.githubusercontent.com/u/13865787?v=4)](https://github.com/MirazMac "MirazMac (17 commits)")[![pronego-mls](https://avatars.githubusercontent.com/u/34332900?v=4)](https://github.com/pronego-mls "pronego-mls (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mirazmac-php-requirements-checker/health.svg)

```
[![Health](https://phpackages.com/badges/mirazmac-php-requirements-checker/health.svg)](https://phpackages.com/packages/mirazmac-php-requirements-checker)
```

PHPackages © 2026

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