/** * retrieve the location of the current install's php.ini as either a file or * directory path. a type can be given as the first param where the value * equates to a file check on "some/path/php.ini" * * @param bool $asfile whether to return the path as a dir or a file location, defaults to FALSE. * @param bool $usedefs whether to filter down the list of fallback/default locations * or not when trying to find a file, defaults to FALSE * * @return string|null NULL on failure otherwise the path in question */ static function getPhpIniLoc($asfile = false, $usedefs = false) { if (!SymfonyApp::isCLI()) throw new Exception('Not for use via http'); $DS = DIRECTORY_SEPARATOR; $Tdir = self::getTargetConfigDir(); // target (most specific) $Sdir = self::getTargetSharedConfigDir(); // target, shared on the basis of 'app mode' $Cdir = self::getSharedConfigDir(); // shared, by all targets (least specific) if (!$usedefs) { $path = $Tdir.$DS.'php.d'.$DS.'php.ini'; if (!file_exists($path)) $path = null; return $path; } $paths = array(); foreach (array($Tdir, $Sdir, $Cdir) as $dir) if ($dir) $paths[] = $dir.$DS.'php.d'.$DS.'php.ini'; while ($path = array_shift($paths)) if (file_exists($path)) return $path; return null; }