Site is the base class and provides a convenient way to access the various Scriptor API classes and variables that can be used to interact with the website and its content. The Site class also inherits all the methods and properties of Module.

First, get the Site class instance:

<?php
use Scriptor\Core\Scriptor;

$site = Scriptor::getSite();

Of course, you can also access the methods and properties of the Site class directly. For example, if you want to access the configuration variable to retrieve the path to the frontend theme:

echo Scriptor::getSite()->config['theme_path'];

If you ever need your current website URL, you can retrieve it this way.

echo Scriptor::getSite()->siteUrl;

You can use the Scriptor::setSite() and Scriptor::getSite() methods to make Scriptor extend the default class, for example to add new methods to Site:

require dirname(__DIR__) . '/site/classes/SiteExtended.php';

Scriptor::setSite('Scriptor\Site\Classes\SiteExtended', true);

$site = Scriptor::getSite();

The method setSite takes 2 parameters. First, the name of the class to be used instead of the Site. Second, an option telling Scriptor to initialize the class after creating the instance (optional). As you can see, we first inject our SiteExtended class into the Scriptor. The PHP file SiteExtended.php could be located in the site/classes/ directory site/classes/SiteExtended.php and could look like this:

<?php // site/classes/SiteExtended.php
namespace Scriptor\Site\Classes;

use Scriptor\Core\Site;

class SiteExtended extends Site
{
    public function getClassName()
    {
        return __CLASS__;
    }
}

Now your class has a new method called getClassName():

echo $site->getClassName(); // output: Scriptor\Site\Classes\SiteExtended