PHPackages                             insider/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. insider/requirements-checker

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

insider/requirements-checker
============================

Intuitive library for checking PHP requirements for your projects

0.1.0(8y ago)129[1 PRs](https://github.com/simondeeley/requirements-checker/pulls)GPL-3.0PHPPHP &gt;=5.3

Since May 19Pushed 8y ago1 watchersCompare

[ Source](https://github.com/simondeeley/requirements-checker)[ Packagist](https://packagist.org/packages/insider/requirements-checker)[ RSS](/packages/insider-requirements-checker/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)DependenciesVersions (3)Used By (0)

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

[](#requirements-checker-for-php)

[![Build Status](https://camo.githubusercontent.com/4fca435faec8aea60c762dd52da214e44e11df647ac3b9fd4996c0baf628b864/68747470733a2f2f7472617669732d63692e6f72672f73696d6f6e6465656c65792f726571756972656d656e74732d636865636b65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/simondeeley/requirements-checker)

#### Library for assessing PHP runtime requirements.

[](#library-for-assessing-php-runtime-requirements)

It provides an intuitive and simple API for checking system requirements at runtime for any PHP script integrating this library. At the moment it supports PHP version and loaded extensions. There are plans to add more checks in the pipeline!

Requirements
------------

[](#requirements)

- PHP &gt;= 5.3.x

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

[](#installation)

```
composer require insider/requirements-checker

```

Usage
-----

[](#usage)

Running any checks that aren't met will throw a `Insider\RequirementsChecker\Exception\RequirementException` error which will hold a message telling you what constraint wasn't met. If all checks pass, then the method returns boolean `true`, allowing you to add it to conditional code in your project, for example you can check that a minimum version of PHP is available:

```
use Insider\RequirementsChecker\VersionRequirement;

$requirement = new VersionRequirement('7.1.2');

if ($requirement->check()) {
    // Do something now we know we have PHP 7.1.2 available
}
```

Check that an extension is loaded

```
use Insider\RequirementsChecker\ExtensionRequirement;

$requirement = new ExtensionRequirement('mcrypt');
$requirement->check();
```

Ensure that the maximum PHP version running is 5.6.7, for example

```
use Insider\RequirementsChecker\VersionRequirement;

$requirement = new VersionRequirement('5.6.7', '=');
$maxRequirement = new VersionRequirement('5.6.7', '=');
$maxRequirement = new VersionRequirement('5.6.7', '
