PHPackages                             natokpe/php-interface - 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. [CLI &amp; Console](/categories/cli)
4. /
5. natokpe/php-interface

ActiveLibrary[CLI &amp; Console](/categories/cli)

natokpe/php-interface
=====================

Tiny PHP package to help you determine whether your PHP app is using a command line interface or a web interface

1.0.0(4y ago)214MITPHPPHP &gt;=7.4

Since Jul 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/natokpe/php-interface)[ Packagist](https://packagist.org/packages/natokpe/php-interface)[ Docs](https://github.com/natokpe/php-interface)[ RSS](/packages/natokpe-php-interface/feed)WikiDiscussions main Synced 1w ago

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

PhpInterface
============

[](#phpinterface)

Use this package to determine what type of interface your PHP app is using to run.

[![Software License](https://camo.githubusercontent.com/472133c874c8f4803666d5a117ef8866a8a4d7956f730291d3af46354d463f44/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e61746f6b70652f7068702d696e74657266616365)](LICENSE)[![release](https://camo.githubusercontent.com/af208c17287cebf9320ac48d6df5fc2945d2e9dd51e2d4e5c531c7e622496342/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6e61746f6b70652f7068702d696e74657266616365)](#)[![repo size](https://camo.githubusercontent.com/fa84fd9dad7b41ac20a039431633dbdd66c2479a97ac53eeb6b27719e8d28fe6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6e61746f6b70652f7068702d696e74657266616365)](#)[![file size](https://camo.githubusercontent.com/c38b5a9207ac07850bf20de0dc0a5c2349751a7a3c00f4ae380161937babb28f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73697a652f6e61746f6b70652f7068702d696e746572666163652f7372632f506870496e746572666163652e706870)](#)

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

[](#installation)

### Composer

[](#composer)

The recommended way of including this package in your project is via Composer

```
$ composer require natokpe/php-interface
```

Usage
-----

[](#usage)

To use the package, you can simply do something like this

```
use Natokpe\PhpInterface\PhpInterface;

require_once __DIR__ . '/vendor/autoload.php';

$interface = new PhpInterface;

echo $interface->which(); // will print 'cli' if PHP is using CLI to run or 'web' if PHP is run from web
```

You can also use either of the `isCli()` or `isWeb()` methods to check

```
if ( $interface->isCli() ) {
  echo 'cli'; // will print 'cli' if PHP is using CLI to run
}

if ( $interface->isWeb() ) {
  echo 'web'; // will print 'web' if PHP is run from web
}
```

Additionally, you may want to know if PHP is using a CGI based interface. Use the `isCgi()` method to check.

```
if ( $interface->isCgi() ) {
  echo 'cgi'; // will print 'cgi' if PHP is using a CGI based interface to run
}
```

You can use PhpInterface without having to instantiate the class via the `getType()` static method, like this

```
echo PhpInterface::getType(); // will print either 'cli' or 'web' depending on which type of interface PHP is using
```

The `getType()` static method is similar to `which()` method.

That's it! I hope you like it and find it useful.

Thank you.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

1756d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f85763ce167ea39c1c6246620d1ad0f3462ecc981d481404bf5f939aba3228b?d=identicon)[natokpe](/maintainers/natokpe)

---

Top Contributors

[![natokpe](https://avatars.githubusercontent.com/u/33991886?v=4)](https://github.com/natokpe "natokpe (15 commits)")

---

Tags

cliwebinterfacesapicgi

### Embed Badge

![Health badge](/badges/natokpe-php-interface/health.svg)

```
[![Health](https://phpackages.com/badges/natokpe-php-interface/health.svg)](https://phpackages.com/packages/natokpe-php-interface)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.3k](/packages/symfony-console)[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k331.8M8.5k](/packages/nunomaduro-collision)[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k239.8M286](/packages/nunomaduro-termwind)[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[wp-cli/php-cli-tools

Console utilities for PHP

68325.0M367](/packages/wp-cli-php-cli-tools)[graste/environaut

Define, configure and protect your application environment and its requirements.

142.7k](/packages/graste-environaut)

PHPackages © 2026

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