Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Gets the current working directory
<?php getcwd(): string|false
<?php         $basePath = $filesystem->normalizePath(realpath(realpath(getcwd())));

        $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));

        $useGlobalIncludePath = (bool) $config->get('use-include-path');

        $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
<?php                             $path

                        );

                        if (empty($installPath)) {

                            $installPath = strtr(getcwd(), '\\', '/');

                        }



                        $resolvedPath = realpath($installPath . '/' . $updir);
<?php         $map = array();

        $filesystem = new Filesystem();

        $cwd = realpath(getcwd());



        foreach ($path as $file) {

            $filePath = $file->getPathname();
<?php         if (empty($validClasses)) {

            foreach ($rejectedClasses as $class) {

                if ($io) {

                    $io->writeError("<warning>Class $class located in ".Preg::replace('{^'.preg_quote(getcwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.</warning>");

                }

            }
<?php         $io->writeError('<info>Creating the archive into "'.$dest.'".</info>');

        $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);

        $fs = new Filesystem;

        $shortPath = $fs->findShortestPath(getcwd(), $packagePath, true);



        $io->writeError('Created: ', false);

        $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
<?php         if (

            ($configFile === 'composer.json' || $configFile === './composer.json')

            && !file_exists($configFile)

            && realpath(getcwd()) === realpath($this->config->get('home'))

        ) {

            file_put_contents($configFile, "{\n}\n");

        }
<?php     public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName = null, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositories = null, $disablePlugins = false, $disableScripts = false, $noProgress = false, $noInstall = false, PlatformRequirementFilterInterface $platformRequirementFilter = null, $secureHttp = true, $addRepository = false)

    {

        $oldCwd = getcwd();



        if ($repositories !== null && !is_array($repositories)) {

            $repositories = (array) $repositories;
<?php             )

        ) {

            $finder = new Finder();

            $finder->depth(0)->directories()->in(getcwd())->ignoreVCS(false)->ignoreDotFiles(false);

            foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_') as $vcsName) {

                $finder->name($vcsName);

            }
<?php         if (null === $directory) {

            $parts = explode("/", $name, 2);

            $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);

        }



        $process = new ProcessExecutor($io);
<?php         $process = new ProcessExecutor($io);

        $fs = new Filesystem($process);

        if (!$fs->isAbsolutePath($directory)) {

            $directory = getcwd() . DIRECTORY_SEPARATOR . $directory;

        }



        $io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(getcwd(), $directory, true) . '"</info>');
<?php             $directory = getcwd() . DIRECTORY_SEPARATOR . $directory;

        }



        $io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(getcwd(), $directory, true) . '"</info>');



        if (file_exists($directory)) {

            if (!is_dir($directory)) {
<?php         if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory()) {

            try {

                chdir($this->getApplication()->getInitialWorkingDirectory());

            } catch (\Exception $e) {
<?php         $this->io = new NullIO();



        $this->initialWorkingDirectory = getcwd();



        parent::__construct('Composer', Composer::getVersion());

    }
<?php         if ($newWorkDir = $this->getNewWorkingDir($input)) {

            $oldWorkingDir = getcwd();

            chdir($newWorkDir);

            $this->initialWorkingDirectory = $newWorkDir;

            $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG);
<?php             $oldWorkingDir = getcwd();

            chdir($newWorkDir);

            $this->initialWorkingDirectory = $newWorkDir;

            $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG);

        }