This method offers just a guess, so don't rely on it.
public static guessBasePath ( ) : string | ||
return | string | The guessed base path that should correspond to the root installation of SimpleSAMLphp. |
/** * CriticalConfigurationError constructor. * * @param string|null $reason The reason for this critical error. * @param string|null $file The configuration file that originated this error. * @param array|null The configuration array that led to this problem. */ public function __construct($reason = null, $file = null, $config = null) { if ($config === null) { $config = self::$minimum_config; $config['baseurlpath'] = \SimpleSAML\Utils\HTTP::guessBasePath(); } \SimpleSAML_Configuration::loadFromArray($config, '', 'simplesaml'); parent::__construct($reason, $file); }
/** * Test SimpleSAML\Utils\HTTP::guessBasePath(). */ public function testGuessBasePath() { $original = $_SERVER; $_SERVER['REQUEST_URI'] = '/simplesaml/module.php'; $_SERVER['SCRIPT_FILENAME'] = '/some/path/simplesamlphp/www/module.php'; $this->assertEquals('/simplesaml/', HTTP::guessBasePath()); $_SERVER['REQUEST_URI'] = '/simplesaml/module.php/some/path/to/other/script.php'; $_SERVER['SCRIPT_FILENAME'] = '/some/path/simplesamlphp/www/module.php'; $this->assertEquals('/simplesaml/', HTTP::guessBasePath()); $_SERVER['REQUEST_URI'] = '/module.php'; $_SERVER['SCRIPT_FILENAME'] = '/some/path/simplesamlphp/www/module.php'; $this->assertEquals('/', HTTP::guessBasePath()); $_SERVER['REQUEST_URI'] = '/module.php/some/path/to/other/script.php'; $_SERVER['SCRIPT_FILENAME'] = '/some/path/simplesamlphp/www/module.php'; $this->assertEquals('/', HTTP::guessBasePath()); $_SERVER['REQUEST_URI'] = '/some/path/module.php'; $_SERVER['SCRIPT_FILENAME'] = '/some/path/simplesamlphp/www/module.php'; $this->assertEquals('/some/path/', HTTP::guessBasePath()); $_SERVER['REQUEST_URI'] = '/some/path/module.php/some/path/to/other/script.php'; $_SERVER['SCRIPT_FILENAME'] = '/some/path/simplesamlphp/www/module.php'; $this->assertEquals('/some/path/', HTTP::guessBasePath()); $_SERVER['REQUEST_URI'] = '/some/dir/in/www/script.php'; $_SERVER['SCRIPT_FILENAME'] = '/some/path/simplesamlphp/www/some/dir/in/www/script.php'; $this->assertEquals('/', HTTP::guessBasePath()); $_SERVER['REQUEST_URI'] = '/simplesaml/some/dir/in/www/script.php'; $_SERVER['SCRIPT_FILENAME'] = '/some/path/simplesamlphp/www/some/dir/in/www/script.php'; $this->assertEquals('/simplesaml/', HTTP::guessBasePath()); $_SERVER = $original; }