Router::fullBaseUrl PHP Method

fullBaseUrl() public static method

## Note: If you change the configuration value App.fullBaseUrl during runtime and expect the router to produce links using the new setting, you are required to call this method passing such value again.
public static fullBaseUrl ( string $base = null ) : string
$base string the prefix for URLs generated containing the domain. For example: ``http://example.com``
return string
    public static function fullBaseUrl($base = null)
    {
        if ($base !== null) {
            static::$_fullBaseUrl = $base;
            Configure::write('App.fullBaseUrl', $base);
        }
        if (empty(static::$_fullBaseUrl)) {
            static::$_fullBaseUrl = Configure::read('App.fullBaseUrl');
        }
        return static::$_fullBaseUrl;
    }

Usage Example

Example #1
0
 /**
  * Tests that the base URL can be changed at runtime.
  *
  * @return void
  */
 public function testBaseUrl()
 {
     $this->assertEquals(FULL_BASE_URL, Router::fullBaseUrl());
     Router::fullBaseUrl('http://example.com');
     $this->assertEquals('http://example.com/', Router::url('/', true));
     $this->assertEquals('http://example.com', Configure::read('App.fullBaseUrl'));
     Router::fullBaseUrl('https://example.com');
     $this->assertEquals('https://example.com/', Router::url('/', true));
     $this->assertEquals('https://example.com', Configure::read('App.fullBaseUrl'));
 }
All Usage Examples Of Router::fullBaseUrl