PHP code example of shipfastlabs / terminal-detector
1. Go to this page and download the library: Download shipfastlabs/terminal-detector library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shipfastlabs / terminal-detector example snippets
use TerminalDetector\TerminalDetector;
$result = TerminalDetector::detect();
if ($result->detected) {
echo "Running inside: {$result->name}";
}
// Check for a specific known terminal
if ($result->knownTerminal() === \TerminalDetector\KnownTerminal::Ghostty) {
echo "Hello from Ghostty!";
}
use function TerminalDetector\detectTerminal;
$result = detectTerminal();
$result->detected; // true / false
$result->name; // e.g. 'iterm2', 'ghostty', 'vscode'
$result->version; // e.g. '3.5.0' (from TERM_PROGRAM_VERSION)
$result->knownTerminal(); // KnownTerminal enum or null
bash
TERMINAL_DETECTOR=my-terminal php script.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.