[Solar-talk] Tutorial: Solar App from Scratch (part 1)

Rodrigo Moraes rodrigo.moraes at gmail.com
Wed Jun 13 00:01:33 PDT 2007


On 6/13/07, anselm bradford wrote:
> In the part where you have:
>
> // Load, build and run Tipos.
> require 'Tipos.php';
> $tipos = new Tipos();
> $tipos->run('config.php');
>
> Where does the config.php file reside?

Hi,
It depends on the include path you have set. It will look on each path
to find the file, so for this:

    set_include_path(
        '/var/www/Framework/'
        . PATH_SEPARATOR . '.'
    );

... it will look in '/var/www/Framework/config.php' and './config.php'
(the same place where index.php is). I keep the config one level above
of the public dir, calling run('../config.php').

It won't work if you put it inside Vendor/App unless this dir is part
of the include path, or if you point directly to it:
run('/Vendor/App/config.php'). It doesn't seem to be a good idea,
anyway. The config is a variable, so you should not put it together
with your classes.

> Also, if you were using the Solar_Front_Controller, what would the
> config file look like?

Something like this:

<?php
$config = array();

// Search for apps in these directories.
$config['Solar_Controller_Front']['classes'] = array(
    'Solar_App',
    'Vendor_App',
);

// Your front controller href.
$config['Solar_Uri_Action']['path'] = '/';
// Your public href.
$config['Solar_Uri_Public']['path'] = '/public';

return $config;


'Solar_Uri_Action' above considers that you are running Solar in the
root path and you use mod_rewrite to rewrite the uri to index.php.
Otherwise you need to adapt the config a bit.

Antti pointed that the config stuff should deserve special attention
in a tutorial. Including how config values are inherited in classes,
etc. I agree, and I hope we'll cover this.

(we're looking for more people willing to write about specific Solar
topics in tutorials; just let us know and we'll organize a community
effort to cover most common topics :)

Btw, which tutorials would you like to see? Also I'm accepting
suggestions about which kind of app should be built in the "Solar App


More information about the solar-talk mailing list