Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HomeCommand.php

function HomeCommand::openBrowser

opens a url in your system default browser

1 call to HomeCommand::openBrowser()
HomeCommand::handlePackage in vendor/composer/composer/src/Composer/Command/HomeCommand.php

File

vendor/composer/composer/src/Composer/Command/HomeCommand.php, line 123

Class

HomeCommand
@author Robert Schönthal <seroscho@googlemail.com>

Namespace

Composer\Command

Code

private function openBrowser(string $url) : void {
    $process = new ProcessExecutor($this->getIO());
    if (Platform::isWindows()) {
        $process->execute([
            'start',
            '"web"',
            'explorer',
            $url,
        ], $output);
        return;
    }
    $linux = $process->execute([
        'which',
        'xdg-open',
    ], $output);
    $osx = $process->execute([
        'which',
        'open',
    ], $output);
    if (0 === $linux) {
        $process->execute([
            'xdg-open',
            $url,
        ], $output);
    }
    elseif (0 === $osx) {
        $process->execute([
            'open',
            $url,
        ], $output);
    }
    else {
        $this->getIO()
            ->writeError('No suitable browser opening command found, open yourself: ' . $url);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal