Skip to content

Commit 1f4c492

Browse files
committed
Detect if running phar via CLI SAPI.
Signed-off-by: GDR! <gdr@gdr.name>
1 parent cc8527a commit 1f4c492

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎php/boot-phar.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
if ( 'cli' !== PHP_SAPI ) {
4+
echo "Only PHP-CLI access.\n";
5+
echo "You're currently using the " . PHP_SAPI . " PHP SAPI.\n";
6+
echo "If you're trying to run this file with a web browser, don't.\n";
7+
echo "When running in command line, ensure that `php -v` has the\n";
8+
echo "word \"cli\" in the first line of output.\n";
9+
die( -1 );
10+
}
11+
312
// Store the path to the Phar early on for `Utils\phar-safe-path()` function.
413
define( 'WP_CLI_PHAR_PATH', getcwd() );
514

0 commit comments

Comments
 (0)