PHPackages                             arcanisgk/web-cli-detector - 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. arcanisgk/web-cli-detector

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

arcanisgk/web-cli-detector
==========================

WEB CLI detector: is a library that allows any development to detect if it is running through the PHP CLI service or a Web Server

v1.07(2y ago)6657MITPHPPHP &gt;=7.4|&gt;=8.0|&gt;=8.1CI passing

Since Jun 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/arcanisgk/WEB-CLI-Detector)[ Packagist](https://packagist.org/packages/arcanisgk/web-cli-detector)[ RSS](/packages/arcanisgk-web-cli-detector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)DependenciesVersions (8)Used By (0)

WEB-CLI-Detector
================

[](#web-cli-detector)

Detection of execution by command (Terminal) or web environment.

Acronym: \[WEB-CLI-Detector\].

Name: WEB-CLI-Detector.

Dependencies: Stand Alone / PHP v7.4.

What does *\[WEB-CLI-Detector\]* do?
------------------------------------

[](#what-does-web-cli-detector-do)

is a very simple PHP \[WEB-CLI-Detector\] implementation that allows you to easily validate if the PHP execution is taking place from a web environment or from the execution of commands (terminal)

Why use *\[WEB-CLI-Detector\]*?
-------------------------------

[](#why-use-web-cli-detector)

Developers need the ability to validate in which environment their libraries or applications are running, this helps decision making depending on the needs or requirements, making it easier for all developers on the same team to use the same validation.

Help to improve *\[WEB-CLI-Detector\]*?
---------------------------------------

[](#help-to-improve-web-cli-detector)

if you want to collaborate with the development of the library; You can express your ideas or report any situation related to this in:

*\[WEB-CLI-Detector\]* Configuration:
-------------------------------------

[](#web-cli-detector-configuration)

None necessary.

*\[WEB-CLI-Detector\]* Installation:
------------------------------------

[](#web-cli-detector-installation)

```
composer require arcanisgk/web-cli-detector
```

*\[WEB-CLI-Detector\]* Usage:
-----------------------------

[](#web-cli-detector-usage)

### Instance of Class:

[](#instance-of-class)

```
use IcarosNet\WebCLIToolKit\WebCLIDetector;
require __DIR__.'\..\vendor\autoload.php';
$wc_detector = new WebCLIDetector();
```

### Implementation of Class:

[](#implementation-of-class)

```
if ($wc_detector->isCLI()) {
    echo 'Running from CLI'.PHP_EOL;
}

if ($wc_detector->isWEB()) {
    echo 'Running from WEB';
}

echo 'Get Raw Environment: '.$wc_detector->getEnvironment();
```

### Other Way to implement:

[](#other-way-to-implement)

this is an option to instance and validate in one line

```
if (WebCLIDetector::getInstance()->isCLI()) {

    //your logic

}
```

### Example Output:

[](#example-output)

CLI Test

[![Image of Example Output1](https://camo.githubusercontent.com/bb0773d88af2c47dbfbc9897a9a6a08cd018dbfb8be2fc92522aa4bf35d1a3ca/68747470733a2f2f692e696d6775722e636f6d2f58725031394d372e706e67)](https://camo.githubusercontent.com/bb0773d88af2c47dbfbc9897a9a6a08cd018dbfb8be2fc92522aa4bf35d1a3ca/68747470733a2f2f692e696d6775722e636f6d2f58725031394d372e706e67)

Web Test

[![Image of Example Output2](https://camo.githubusercontent.com/0374de5d358e27042d2f63bbd0e11dfe7a26af783afebbce2e773550c5d37155/68747470733a2f2f692e696d6775722e636f6d2f675177596c6d4f2e706e67)](https://camo.githubusercontent.com/0374de5d358e27042d2f63bbd0e11dfe7a26af783afebbce2e773550c5d37155/68747470733a2f2f692e696d6775722e636f6d2f675177596c6d4f2e706e67)

### Contributors

[](#contributors)

- (c) 2020 - 2022 Walter Francisco Núñez Cruz  [![Donate](https://camo.githubusercontent.com/a52580597c15a106bc32b9769f9a7327c177653898360f8052c301029f51a7b7/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d446f6e617465266d6573736167653d50617950616c2e6d652f776e756e657a383626636f6c6f723d627269676874677265656e)](https://www.paypal.me/wnunez86/4.99USD)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~72 days

Recently: every ~108 days

Total

7

Last Release

1005d ago

PHP version history (2 changes)v1.0.1PHP ^7.4

v1.07PHP &gt;=7.4|&gt;=8.0|&gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![wnunezc](https://avatars.githubusercontent.com/u/1207306?v=4)](https://github.com/wnunezc "wnunezc (11 commits)")

### Embed Badge

![Health badge](/badges/arcanisgk-web-cli-detector/health.svg)

```
[![Health](https://phpackages.com/badges/arcanisgk-web-cli-detector/health.svg)](https://phpackages.com/packages/arcanisgk-web-cli-detector)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M19](/packages/consolidation-annotated-command)[chi-teck/drupal-code-generator

Drupal code generator

26947.8M5](/packages/chi-teck-drupal-code-generator)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)

PHPackages © 2026

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