src/ChromeDevtoolsProtocol/Instance/Launcher.php
public function launch(ContextInterface $ctx, ...$args): ProcessInstance
	{
		if ($this->executable) {
			$executable = $this->executable;

		} else if (PHP_OS === "Linux") {
			$finder = new ExecutableFinder();
			$executable = $finder->find(static::DEFAULT_LINUX_EXECUTABLE);
			if ($executable === null) {
				throw new RuntimeException(sprintf("Executable [%s] not found.", static::DEFAULT_LINUX_EXECUTABLE));
			}

		} else if (strncasecmp(PHP_OS, "Win", 3) === 0) {
			$finder = new ExecutableFinder();
			$executable = $finder->find(static::DEFAULT_WINDOWS_EXECUTABLE);
			if ($executable === null) {
				throw new RuntimeException(sprintf("Executable [%s] not found.", static::DEFAULT_WINDOWS_EXECUTABLE));
			}

		} else if (PHP_OS === "Darwin") {
			$candidateExecutables = [
				// Chrome Canary
				"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
				// Chrome Stable
				"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
			];

			$executable = null;
			foreach ($candidateExecutables as $candidateExecutable) {
				if (is_executable($candidateExecutable)) {
					$executable = $candidateExecutable;
					break;
				}
			}

			if ($executable === null) {
				throw new RuntimeException(sprintf("No OS X executable found."));
			}

		} else {
			throw new LogicException(sprintf("Operating system [%s] not supported.", PHP_OS));
		}

		return $this->launchWithExecutable($ctx, $executable, ...$args);
	}
public function launch(ContextInterface $ctx, ...$args): ProcessInstance
	{
		if ($this->executable) {
			$executable = $this->executable;

		} else if (PHP_OS === "Linux") {
			$finder = new ExecutableFinder();
			$executable = $finder->find(static::DEFAULT_LINUX_EXECUTABLE);
			if ($executable === null) {
				throw new RuntimeException(sprintf("Executable [%s] not found.", static::DEFAULT_LINUX_EXECUTABLE));
			}

		} else if (strncasecmp(PHP_OS, "Win", 3) === 0) {
			$finder = new ExecutableFinder();
			$executable = $finder->find(static::DEFAULT_WINDOWS_EXECUTABLE);
			if ($executable === null) {
				throw new RuntimeException(sprintf("Executable [%s] not found.", static::DEFAULT_WINDOWS_EXECUTABLE));
			}

		} else if (PHP_OS === "Darwin") {
			$candidateExecutables = [
				// Chrome Canary
				"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
				// Chrome Stable
				"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
			];

			$executable = null;
			foreach ($candidateExecutables as $candidateExecutable) {
				if (is_executable($candidateExecutable)) {
					$executable = $candidateExecutable;
					break;
				}
			}

			if ($executable === null) {
				throw new RuntimeException(sprintf("No OS X executable found."));
			}

		} else {
			throw new LogicException(sprintf("Operating system [%s] not supported.", PHP_OS));
		}

		return $this->launchWithExecutable($ctx, $executable, ...$args);
	}
public function launch ( ContextInterface $ ctx , ... $ args ) : ProcessInstance { if ( $ this -> executable ) { $ executable = $ this -> executable ; } else if ( PHP_OS === "Linux" ) { $ finder = new ExecutableFinder ( ) ; $ executable = $ finder -> find ( static :: DEFAULT_LINUX_EXECUTABLE ) ; if ( $ executable === null ) { throw new RuntimeException ( sprintf ( "Executable [%s] not found." , static :: DEFAULT_LINUX_EXECUTABLE ) ) ; } } else if ( strncasecmp ( PHP_OS , "Win" , 3 ) === 0 ) { $ finder = new ExecutableFinder ( ) ; $ executable = $ finder -> find ( static :: DEFAULT_WINDOWS_EXECUTABLE ) ; if ( $ executable === null ) { throw new RuntimeException ( sprintf ( "Executable [%s] not found." , static :: DEFAULT_WINDOWS_EXECUTABLE ) ) ; } } else if ( PHP_OS === "Darwin" ) { $ candidateExecutables = [ // Chrome Canary "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary" , // Chrome Stable "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" , ] ; $ executable = null ; foreach ( $ candidateExecutables as $ candidateExecutable ) { if ( is_executable ( $ candidateExecutable ) ) { $ executable = $ candidateExecutable ; break ; } } if ( $ executable === null ) { throw new RuntimeException ( sprintf ( "No OS X executable found." ) ) ; } } else { throw new LogicException ( sprintf ( "Operating system [%s] not supported." , PHP_OS ) ) ; } return $ this -> launchWithExecutable ( $ ctx , $ executable , ... $ args ) ; }
Start new Chrome process.

@param ContextInterface $ctx
@param array ...$args
@return ProcessInstance
@throws \Exception
Start new Chrome process .