PHPackages                             brightnucleus/phpfeature - 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. brightnucleus/phpfeature

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

brightnucleus/phpfeature
========================

PHP Feature Detection Library

v0.2.7(7y ago)620[6 issues](https://github.com/brightnucleus/phpfeature/issues)MITPHP

Since Jan 13Pushed 7y ago1 watchersCompare

[ Source](https://github.com/brightnucleus/phpfeature)[ Packagist](https://packagist.org/packages/brightnucleus/phpfeature)[ RSS](/packages/brightnucleus-phpfeature/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (10)Used By (0)

PHPFeature
==========

[](#phpfeature)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1e0a12c60aa912964cf7ce0c352480dddf1c39c86c77efb4af09300231bfc7fe/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6272696768746e75636c6575732f706870666561747572652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/brightnucleus/phpfeature/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/b353c2c80755715e3bc62e39c9246431707030166cb0cf74fef69e116924393d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6272696768746e75636c6575732f706870666561747572652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/brightnucleus/phpfeature/?branch=master)[![Build Status](https://camo.githubusercontent.com/61a72cf02c932d5e6993fb6b0580521abc3b0e10e3647df70e492fcae3b40f57/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6272696768746e75636c6575732f706870666561747572652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/brightnucleus/phpfeature/build-status/master)[![Codacy Badge](https://camo.githubusercontent.com/3e9d3918f2541b6b4c3017db4d0eb262a6b49fe59b326afa9768b57c3617e7b9/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f67726164652f3266626332366134353338303434336338303465663864653562613037663333)](https://www.codacy.com/app/BrightNucleus/phpfeature)[![Code Climate](https://camo.githubusercontent.com/ca7efe14d4a82003b58ad9636393110ea45f9c40bb3f36a27a089306dc329773/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6272696768746e75636c6575732f706870666561747572652f6261646765732f6770612e737667)](https://codeclimate.com/github/brightnucleus/phpfeature)

[![Latest Stable Version](https://camo.githubusercontent.com/bfe43b8d6cb53d23a53a755fb6749d929fe29aed5eda1a7185ff5a6ade601ec4/68747470733a2f2f706f7365722e707567782e6f72672f6272696768746e75636c6575732f706870666561747572652f762f737461626c65)](https://packagist.org/packages/brightnucleus/phpfeature)[![Total Downloads](https://camo.githubusercontent.com/6a54170a32293d0d7463cfae5448dc4214eea234ffba1e85df75064c363426c6/68747470733a2f2f706f7365722e707567782e6f72672f6272696768746e75636c6575732f706870666561747572652f646f776e6c6f616473)](https://packagist.org/packages/brightnucleus/phpfeature)[![Latest Unstable Version](https://camo.githubusercontent.com/46bbefd44f22f07c63bfb19af43d34e3b2ad3f49c2a1c3729d83a1dfc535598b/68747470733a2f2f706f7365722e707567782e6f72672f6272696768746e75636c6575732f706870666561747572652f762f756e737461626c65)](https://packagist.org/packages/brightnucleus/phpfeature)[![License](https://camo.githubusercontent.com/37829c311083ebc4e45bed08d00474e3ebb8a61c36c4ababb8a1066df5b66906/68747470733a2f2f706f7365722e707567782e6f72672f6272696768746e75636c6575732f706870666561747572652f6c6963656e7365)](https://packagist.org/packages/brightnucleus/phpfeature)

PHPFeature is a first draft of a PHP Feature Detection Library similar to what Modernizr does for the browser features. So, instead of checking for a specific PHP version number (which forces you to know which and compare which features were introduced by which versions), you can simply tell the library what features you need, and it will tell you with a simple boolean value whether these are supported or not.

You can read more background information here:

Table Of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Known Issues](#known-issues)
- [Contributing](#contributing)
- [License](#license)

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

[](#requirements)

To develop using the library, you will need PHP 5.3.2+, as it uses Composer to manage its dependencies.

However, the runtime code only requires PHP 5.2+, as one of the goals was to make it useful for WordPress development.

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

[](#installation)

To include the library in your project, you can use Composer:

```
composer require brightnucleus/phpfeature
```

Alternatively, you can copy the classes inside of your application and make sure that your application can find them.

Basic Usage
-----------

[](#basic-usage)

Usage is pretty simple, it only comes with two methods so far.

```
public function is_supported( $features );
```

This returns a boolean value telling you whether all of the features that you passed in are supported by the current PHP version.

```
public function get_minimum_required( $features );
```

This returns a SemanticVersion object that contains the minimum PHP version that supports all of the features that you passed in.

Here’s an example of how to use it to stop execution and inform the user:

```
// Array of strings to define what features you need.
$features = array( 'namespaces', 'traits' );

// Instantiate the PHPFeature library.
// When you don't provide a version number as the first argument,
// the version of the currently used PHP interpreter is fetched.
$php = new PHPFeature();

// Check whether all of the features are supported. If not...
if ( ! $php->is_supported( $features ) ) {

    // ... throw exception and let user know the minimum needed.
    throw new RuntimeException( sprintf(
        'Your PHP interpreter does not support some features needed to run this application. Please upgrade to version %1$s or newer.',
        $php->get_minimum_required( $features )
    ) );
}
```

Known Issues
------------

[](#known-issues)

- The library currently uses PHP's `version_compare()` to make the actual comparison. This should probably be done by a real SemVer comparison algorithm.
- The list of features is not yet exhaustive. There should also be some guidelines to know how these are named.
- The algorithm behind `get_minimum_required()` is still very basic, and `NotEqual` is not implemented.

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

[](#contributing)

All feedback / bug reports / pull requests are welcome.

License
-------

[](#license)

This code is released under the MIT license. For the full copyright and license information, please view the LICENSE file distributed with this source code.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~145 days

Recently: every ~290 days

Total

9

Last Release

2610d ago

### Community

Maintainers

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

---

Top Contributors

[![schlessera](https://avatars.githubusercontent.com/u/83631?v=4)](https://github.com/schlessera "schlessera (43 commits)")

---

Tags

hacktoberfest

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/brightnucleus-phpfeature/health.svg)

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

###  Alternatives

[amasty/module-mage-248-fix

Fix several issues on Magento 2.4.8 version by Amasty

11138.7k](/packages/amasty-module-mage-248-fix)

PHPackages © 2026

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