The Solar::start() method starts the Solar environment; it is usually the very first method call you make after including the Solar.php file in your bootstrap script. It loads the configuration values, cleans up $GLOBALS, and so on.
<?php
require_once 'Solar.php';
Solar::start('/path/to/config/Solar.config.php');
// the rest of your script
Solar::stop();
?>
The start() method performs a number of activities for you to set up the execution environment:
Reads the config file into Solar::$config.
Processes the Solar::$config['Solar']['ini_set'] key/value pairs using
ini_set().
Registers a 'locale' object to handle localization strings, and a 'request' object to represent the request environment (especially superglobal values). Uses the Solar_Registry class for this.
Finally, Solar runs any scripts noted in Solar::$config['Solar']['start'].
This allows you to specify additional environment startup behaviors.
The Solar::$config array stores the values read in from Solar.config.php, also known as the config file. In general, you should not access the $config property directly; instead, read from it using Solar::config().
As a counterpart to Solar::start(), the Solar::stop() method shuts down the Solar environment.
<?php
require_once 'Solar.php';
Solar::start('/path/to/config/Solar.config.php');
// the rest of the script goes here
Solar::stop();
?>
Effectively, all this does it execute any scripts named in Solar::$config['Solar']['stop']. This allows you to run shutdown scripts particular to your system.
You can configure the Solar class using these keys.
| key | value |
|---|---|
ini_set |
(array) ini_set() parameters |
start |
(array) custom startup scripts |
stop |
(array) custom shutdown scripts |
locale_class |
(string) the class to use for locales, default Solar_Locale |
These config key values get called as part of the Solar::start() process. For example, if you have this in Solar::$config ...
<?php
$config['Solar']['ini_set']['display_errors'] = true;
?>
... Solar::start() will issue ini_set('display_errors', true) as part of the startup process.
These values represent scripts to execute as part of Solar::start(). For example, if you have this in Solar::$config ...
<?php
$config['Solar']['start'][] = '/path/to/start1.php';
$config['Solar']['start'][] = '/path/to/start2.php';
?>
... then Solar::start() will run start1.php and start2.php as part of its startup process.
These values represent scripts to execute as part of Solar::stop(). For example, if you have this in Solar::$config ...
<?php
$config['Solar']['stop'][] = '/path/to/stop1.php';
$config['Solar']['stop'][] = '/path/to/stop2.php';
?>
... then Solar::stop() will run stop1.php and stop2.php as part of its
shutdown process.