diff --git a/server-command.php b/server-command.php index 9ad8ad5..3714abb 100644 --- a/server-command.php +++ b/server-command.php @@ -9,4 +9,11 @@ require_once $autoload; } -WP_CLI::add_command( 'server', 'Server_Command', array() ); +WP_CLI::add_command( 'server', 'Server_Command', array( + 'before_invoke' => function() { + $min_version = '5.4'; + if ( version_compare( PHP_VERSION, $min_version, '<' ) ) { + WP_CLI::error( "The `wp server` command requires PHP {$min_version} or newer." ); + } + } +) ); diff --git a/src/Server_Command.php b/src/Server_Command.php index 930d416..d13b555 100644 --- a/src/Server_Command.php +++ b/src/Server_Command.php @@ -55,11 +55,6 @@ class Server_Command extends WP_CLI_Command { * @when before_wp_load */ function __invoke( $_, $assoc_args ) { - $min_version = '5.4'; - if ( version_compare( PHP_VERSION, $min_version, '<' ) ) { - WP_CLI::error( "The `wp server` command requires PHP $min_version or newer." ); - } - $defaults = array( 'host' => 'localhost', 'port' => 8080,