Returns the location of composer.

@return string
334454
public static function getComposerLocation()
    {
        if (!\function_exists('shell_exec') || stripos(PHP_OS, 'win') === 0) {
            return self::DEFAULT_PATH;
        }

        // check for global composer install
        $path = trim(shell_exec('command -v composer'));

        // fall back to grav bundled composer
        if (!$path || !preg_match('/(composer|composer\.phar)$/', $path)) {
            $path = self::DEFAULT_PATH;
        }

        return $path;
    }
314207
public function getConfigFilePath()
    {
        $path = null;
        $locator = $this->config->getLocator();

        if (is_array($this->file)) {
            $res = null;
            foreach ($this->file as $file) {
                if (($res = $locator->locate($file)) !== false) {
                    break;
                }
            }
            $path = $res->getPath();
        } else {
            $path = $locator->locate($this->file)->getPath();
        }

        return $path;
    }
1275001
private function locateLocal($key)
    {
        $composerConfig = $this->composer->getConfig();

        // Sorry for this, I couldn't find any way to get the path of the current root package
        $reflection = new \ReflectionClass($composerConfig);
        $property = $reflection->getProperty('baseDir');
        $property->setAccessible(true);

        $path = $property->getValue($composerConfig);

        $localComposerExtra = $this->composer->getPackage()->getExtra();

        if (array_key_exists($key, $localComposerExtra)) {
            $this->cache[$key] = [
                'found' => true,
                'config' => $localComposerExtra[$key],
                'path' => $path,
            ];

            return true;
        }

        return false;
    }
1193622
public function find()
    {
        $config = $this->container['config']->get('rinvex.modulable');

        foreach ($config['paths'] as $path) {
            foreach ($this->container['files']->glob($path.'/*/*/composer.json') as $module) {
                // Exclude core module and any non-cortex modules
                if (mb_strpos($module, 'cortex/foundation') === false && ($json = json_decode($this->container['files']->get($module), true))
                    && in_array($json['type'], $config['types']) && in_array($json['name'], $config['enabled'])) {
                    $json['path'] = dirname(realpath($module));
                    $json['namespace'] = array_first(array_keys(array_pull($json, 'autoload.psr-4')));
                    $json['aggregator'] = $this->container['files']->exists($json['path'].'/src/Providers/AggregateServiceProvider.php')
                        ? $json['namespace'].'Providers\AggregateServiceProvider' : null;

                    $this->modules[$json['name']] = new Module($this->container, $json);
                }
            }
        }

        return $this;
    }
183869
public function getVersion()
  {
    $composerJson = config('app.dir') . 'composer.json';

    if (file_exists($composerJson)) {
      $composer = json_decode(file_get_contents($composerJson, true));

      $version  = isset($composer->version) ? $composer->version : '1';
      $require  = isset($composer->require) ? (array)$composer->require : false;

      if (!is_array($require)) return "{$version} (1)";

      if (isset($require['modulusphp/framework'])) {
        return $version . " ({$require['modulusphp/framework']})";
      } else {
        return "{$version} (1)";
      }
    }

    return '1';
  }
1196140
public function getLocalPackages() {
		$composer = $this->getComposer();
		$dispatcher = new EventDispatcher($composer, $this->io);
		$autoloadGenerator = new \Composer\Autoload\AutoloadGenerator($dispatcher);
		
		if ($this->selfEdit) {
			chdir(__DIR__."/../../..");
			\putenv('COMPOSER=composer-mouf.json');
		} else {
			chdir(__DIR__."/../../../../../..");
		}
		//TODO: this call is strange because it will return the same isntance as above.
		$composer = $this->getComposer();
				
		$localRepos = new CompositeRepository(array($composer->getRepositoryManager()->getLocalRepository()));
		$package = $composer->getPackage();
		$packagesList = $localRepos->getPackages();
		$packagesList[] = $package;
		
		return $packagesList;
	}
1260378
public function getVendorPath()
    {
        if (is_null($this->vendorPath)) {
            // We get the current package install path
            $installPath = $this->composer->getInstallationManager()->getInstallPath($this->package);
            // We get the name of the package in order to get its target path
            $targetDir = $this->package->getName();
            // We remove this target path to isolate the vendor path only
            $this->vendorPath = explode($targetDir, $installPath)[0];
        }
        return $this->vendorPath;
    }
875207
public function getVendorDirectoryPath()
    {
        $path = (string) Mage::getConfig()->getNode('global/composer_autoloader/path');
        if (!$path) {
            $path = self::DEFAULT_PATH;
        }

        $path = str_replace('/', DS, $path);
        $path = str_replace('{{basedir}}', Mage::getBaseDir(), $path);
        $path = str_replace('{{libdir}}', Mage::getBaseDir('lib'), $path);
        $path = rtrim($path, DS);
        return realpath($path);
    }
1174559
protected function findFilePath()
    {
        $filename = static::FILE_NAME;

        foreach ($this->defaultLocations() as $location) {
            if (file_exists("{$location}/$filename")) {
                return $location;
            }
        }

        return $this->defaultFilePath();
    }
687740
protected function retrieveBundleWebFolder()
    {
        $asset = $this->asset;
        
        $namespacesFile = $this->kernel->getRootDir() . '/../vendor/composer/autoload_namespaces.php';
        if (file_exists($namespacesFile)) {
            $map = require $namespacesFile;
            foreach ($map as $namespace => $paths) {
                if ( ! is_array($paths)) {
                    $paths = array($paths);
                }
                
                foreach($paths as $path) {
                    if (strpos($this->asset, $path) !== false) {
                        preg_match('/Bundle(.*)/', $this->asset, $matches);
                        $asset = str_replace("\\", "", $namespace) . $matches[1];
                        break;
                    }
                }
            }
        }

        preg_match('/([^@\/][\w]+Bundle)\/(Resources\/public)?\/(.*)/', $asset, $matches);
        if (!empty($matches) && count($matches) == 4) {
            return sprintf('bundles/%s/%s', preg_replace('/bundle$/', '', strtolower($matches[1])), $matches[3]);
        }

        preg_match('/[\/]?(bundles.*)/', strtolower($asset), $matches);
        if (!empty($matches)) {
            return $matches[1];
        }

        $asset = str_replace("@", "", strtolower($asset));
        $bundleDir = preg_replace('/bundle$/', '', $asset);

        return ($bundleDir !== $asset) ? 'bundles/' . $bundleDir : null;
    }
989901
protected function findComposer()
    {
        $basedir = $this->project->getBasedir();
        $php = $this->project->getProperty('php.interpreter');

        if (file_exists($basedir . '/composer.phar')) {
            $this->composer = "$php $basedir/composer.phar";
        } else {
            $out = array();
            exec('which composer', $out);
            if (empty($out)) {
                throw new BuildException(
                    'Could not determine composer location.'
                );
            }
            $this->composer = $out[0];
        }
    }
403842
private function guessComposerCommand()
    {
        $candidateNames = array('composer', 'composer.phar');

        $executableFinder = new ExecutableFinder();
        foreach ($candidateNames as $candidateName) {
            if ($composerPath = $executableFinder->find($candidateName, null, array(getcwd()))) {
                return array(realpath($composerPath));
            }
        }

        foreach ($candidateNames as $candidateName) {
            $composerPath = sprintf('%s/%s', getcwd(), $candidateName);
            if (file_exists($composerPath)) {
                $phpFinder = new PhpExecutableFinder();

                return array_merge(
                    array(
                        $phpFinder->find(false),
                        $composerPath,
                    ),
                    $phpFinder->findArguments()
                );
            }
        }

        return;
    }
339984
public function getLocalPath()
    {
        if (!$this->localPath) {
           $this->localPath = $this->repository->resolveLocalPath($this->fullPath);
        }
        return $this->localPath;
    }
922102
private static function getCustomVendorPathFromComposer($composerConfigurationPath): string
    {
        $composerFile = file_get_contents($composerConfigurationPath);
        $composerJson = json_decode($composerFile, true);
        return $composerJson['config']['vendor-dir'] ?? 'vendor';
    }
655983
public static function getComposerVendorPath()
    {
        $reflection = new ReflectionClass(ClassLoader::class);
        $vendorDir = dirname(dirname($reflection->getFileName()));
        if (!$vendorDir) {
            throw new NotFoundException('cannot find composer vendor path');
        }

        return $vendorDir;
    }
1183404
public function getRelativePath()
    {
        $current = realpath('./');

        if ($current !== false && strpos(self::$path.'/', $current.'/') === 0) {
            return rtrim('./' . substr(self::$path, strlen($current) + 1), '\\/');
        }

        throw new \InvalidArgumentException(
            'Unable to resolve relative path to Textpattern installation location '.
            'from the current working directory.'
        );
    }
348498
protected function getComposer()
    {
        if ($autoloaders = spl_autoload_functions()) {
            foreach ($autoloaders as $autoload) {
                if (is_array($autoload)) {
                    $class = $autoload[0];
                    if ('Composer\Autoload\ClassLoader' == get_class($class)) {
                        return $class;
                    }
                }
            }
        }
    }