AppserverIo\Appserver\Application\Application::getBaseDirectory PHP Method

getBaseDirectory() public method

Returns the absolute path to the servers document root directory
public getBaseDirectory ( string $directoryToAppend = null ) : string
$directoryToAppend string The directory to append to the base directory
return string The base directory with appended dir if given
    public function getBaseDirectory($directoryToAppend = null)
    {
        $baseDirectory = $this->getNamingDirectory()->search('php:env/baseDirectory');
        if ($directoryToAppend != null) {
            $baseDirectory .= $directoryToAppend;
        }
        return $baseDirectory;
    }

Usage Example

Example #1
0
 /**
  * Test if the passed directory will be appended correctly.
  *
  * @return void
  */
 public function testGetBaseDirectoryWithDirectoryToAppend()
 {
     // create a directory
     $aDirectory = ApplicationTest::BASE_DIRECTORY . DIRECTORY_SEPARATOR . ApplicationTest::NAME;
     // inject the base directory
     $this->assertEquals($aDirectory, $this->application->getBaseDirectory(DIRECTORY_SEPARATOR . ApplicationTest::NAME));
 }