diff --git a/features/server.feature b/features/server.feature index badb0f2..ba3f573 100644 --- a/features/server.feature +++ b/features/server.feature @@ -32,6 +32,24 @@ Feature: Serve WordPress locally 256M """ + Scenario: Custom ini configuration + Given a WP install + And a mem.php file: + """ + + """ + And a custom.ini file: + """ + memory_limit = 512M + """ + And I launch in the background `wp server --host=localhost --port=8188 --config=custom.ini` + + When I run `curl -sS localhost:8188/mem.php` + Then STDOUT should be: + """ + 512M + """ + Scenario: Access wp-login.php Given a WP install And I launch in the background `wp server --host=localhost --port=8185` diff --git a/src/Server_Command.php b/src/Server_Command.php index 1e33023..0faa860 100644 --- a/src/Server_Command.php +++ b/src/Server_Command.php @@ -125,17 +125,23 @@ public function __invoke( $args, $assoc_args ) { } // Add the server flags - $cmd_format .= ' -S %s -t %s -c %s %s'; + $cmd_format .= ' -S %s -t %s'; $cmd_args[] = $assoc_args['host'] . ':' . $assoc_args['port']; - $cmd_args[] = $docroot; - $cmd_args[] = $assoc_args['config']; + $cmd_args[] = (string) $docroot; + + if ( ! empty( $assoc_args['config'] ) && is_string( $assoc_args['config'] ) ) { + $cmd_format .= ' -c %s'; + $cmd_args[] = $assoc_args['config']; + } + + $cmd_format .= ' %s'; $cmd_args[] = Utils\extract_from_phar( $router_path ); $cmd = Utils\esc_cmd( $cmd_format, ...$cmd_args ); $descriptors = array( STDIN, STDOUT, STDERR ); - if ( Utils\get_flag_value( $assoc_args, 'adapt-scheme', false ) ) { // @phpstan-ignore argument.type + if ( Utils\get_flag_value( $assoc_args, 'adapt-scheme', false ) ) { putenv( 'WPCLI_SERVER_ADAPT_SCHEME=1' ); }