Skip to content

Bug: There's no way to change default spark serve port using code #2966

Description

@willnode

Describe the bug
I'm trying to create a custom CLI command to spark serve --port 4000. I tried this:

namespace App\Commands;

use CodeIgniter\CLI\BaseCommand;

class Start extends BaseCommand
{
	protected $group       = 'App';
	protected $name        = 'start';
	protected $description = 'Start Server on Port 4000';

	public function run(array $params)
	{
		$this->call('serve', ['-port', '4000']);
	}
}

And running php spark start. However it serving port 8080 instead.

My best guess that it's happened because the $params argument is not considered in Serve.php:

public function run(array $params)

// Collect any user-supplied options and apply them.
$php = escapeshellarg(CLI::getOption('php') ?? PHP_BINARY);
$host = CLI::getOption('host') ?? 'localhost';
$port = (int) (CLI::getOption('port') ?? '8080') + $this->portOffset;

CodeIgniter 4 version
Latest version

Affected module(s)
None, I think

Expected behavior, and steps to reproduce if appropriate
It's serving at the custom port (4000)

Context

  • OS: Windows 10 64 Bit
  • PHP version 7.3.9

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions