| Recommend this page to a friend! |
| Info | Example | Reputation | Support forum | Blog | Links |
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not enough user ratings | Total: 88 This week: 1 | All time: 9,993 This week: 42 | ||||
| Version | License | PHP version | Categories | |||
| web-cli-detector 1.0.5 | MIT/X Consortium ... | 7.4 | PHP 5, System information, Console |
<?php |
Detection of execution by command (Terminal) or web environment.
Acronym: [WEB-CLI-Detector].
Name: WEB-CLI-Detector.
Dependencies: Stand Alone / PHP v7.4.
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)
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.
if you want to collaborate with the development of the library; You can express your ideas or report any situation related to this in: https://github.com/arcanisgk/WEB-CLI-Detector/issues
None necessary.
composer require arcanisgk/web-cli-detector
or
composer require arcanisgk/web-cli-detector --dev
use IcarosNet\WebCLIDetector\WebCLIDetector;
require __DIR__.'\..\vendor\autoload.php';
$wc_detector = new WebCLIDetector();
if ($wc_detector->isCLI()) {
echo 'Running from CLI'.PHP_EOL;
}
if ($wc_detector->isWEB()) {
echo 'Running from WEB<br>';
}
echo 'Get Raw Environment: '.$wc_detector->getEnvironment();
this is an option to instance and validate in one line
if (WebCLIDetector::getInstance()->isCLI()) {
//your logic
}
CLI Test

Web Test

| File | Role | Description | ||
|---|---|---|---|---|
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Lic. | License text | |||
| Doc. | Documentation | |||
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% |
|
|
| User Comments (1) | |||||
| |||||
| Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.