The Solar configuration file
The main Solar manual has a really good section on setting up and working with the Solar config file. Be sure to read the information posted there as well.
Setting up the config
Once you get Solar installed, you will probably want to tweak some settings, such as your database configuration. One of the features I like the most is Solar’s unified configuration file with its tight integration into each controller. The configuration file is simply a returned array, and entries in the configuration file use the name of the class as an array key. Those values are then available to the class via $this->_config. Below is an example.
// Snippet taken from Solar.config.ini $config['Vendor_App_Example'] = array( 'date_format'=>'Y-m-d' );
Then, let’s assume you have a controller named Vendor_App_Example:
<?php class Vendor_App_Example extends Solar_Controller_Page { public function actionIndex() { // $this->_config is automatically available and // has the values from $config['Vendor_App_Example'] $date_format = $this->_config['date_format']; } } ?>
Accessing other configuration setting is easy too. For example, you might want to know what the system and autoload-include directory is set to. In the Solar.config.php file, this is set up like the following:
/** * system and autoload-include directories */ $system = dirname(dirname(__FILE__)); $config['Solar']['system'] = $system;
Accessing that variable in your controller is as easy as this:
$system = Solar::config('Solar', 'system');
Much more information about reading config variables is available in Solar’s online manual.
Front Controller
One of the sections of the Solar.config.php file that you will want to customize is the section setting up the front controller. This section allows you to specify what application classes you want available to Solar, which should be the default controller, plus any controllers you want ignored or disabled.
Here is an example from the Solar.config.ini file:
/** * front controller */ $config['Solar_Controller_Front'] = array( 'classes' => array('Solar_App', 'Vendor_App'), 'disable' => array('base'), 'default' => 'hello', 'routing'=> array('bonjour'=>'Solar_App_Hello'), );
In this example, the classes we want available are Solar_App_* and Vendor_App_*. We don’t want any methods in Solar_App_Base or Vendor_App_Base to be available to the browser directly, so we set ‘base’ as disabled. The default controller is hello, so if you requested http://www.example.com, Solar would run the default method in Solar_App_Hello. Finally, we want requests for http://www.example.com/bonjour to be the same as if we requested http://www.example.com/hello.
This is a very brief intoduction to the Solar config file, but it should be enough to get you started. As I mentioned a few times, there is lots of information about the configuration file in the online Solar manual.
Next time, we might actually generate some browser output!
[...] The Solar configuration file [...]
[...] A more in-depth look at the solar configuration file [...]
[...] http://elofson.ca/2009/03/the-solar-configuration-file [...]