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

Breadcrumb

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

function EventDispatcher::ensureBinDirIsInPath

1 call to EventDispatcher::ensureBinDirIsInPath()
EventDispatcher::doDispatch in vendor/composer/composer/src/Composer/EventDispatcher/EventDispatcher.php
Triggers the listeners of an event.

File

vendor/composer/composer/src/Composer/EventDispatcher/EventDispatcher.php, line 654

Class

EventDispatcher
The Event Dispatcher.

Namespace

Composer\EventDispatcher

Code

private function ensureBinDirIsInPath() : void {
    $pathEnv = 'PATH';
    // checking if only Path and not PATH is set then we probably need to update the Path env
    // on Windows getenv is case-insensitive so we cannot check it via Platform::getEnv and
    // we need to check in $_SERVER directly
    if (!isset($_SERVER[$pathEnv]) && isset($_SERVER['Path'])) {
        $pathEnv = 'Path';
    }
    // add the bin dir to the PATH to make local binaries of deps usable in scripts
    $binDir = $this->composer
        ->getConfig()
        ->get('bin-dir');
    if (is_dir($binDir)) {
        $binDir = realpath($binDir);
        $pathValue = (string) Platform::getEnv($pathEnv);
        if (!Preg::isMatch('{(^|' . PATH_SEPARATOR . ')' . preg_quote($binDir) . '($|' . PATH_SEPARATOR . ')}', $pathValue)) {
            Platform::putEnv($pathEnv, $binDir . PATH_SEPARATOR . $pathValue);
        }
    }
}

API Navigation

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