coWiki 0.3.4
Current user:   guest   Change Preferences
   List directory   History   Similar   Print version 
   Getting Started 
   Database Abstraction 

hosted by: Webhosting

Please donate to keep Sourdough a free software
Do you like Sourdough?
Keep it a free software!

Documentation > Getting Started

rw-rw-r--   iezzip   users

Getting Started

Sourdough Structure

Before we begin using Sourdough, you should take a moment to familiarize yourself with the Sourdough directory structure.

|-- Sourdough.class.php        # <-- global Sourdough object
|-- core.function.php
|-- Sd_Db
|   |-- Sd_DbDatatype
|   |-- Sd_DbLibrary
|   |-- drivers
|   |   |-- fbase
|   |   |-- ibase
|   |   |-- mssql
|   |   |-- mysql
|   |   |-- mysqli
|   |   |-- pgsql
|   |   |-- sqlite
|   |   `-- sybase
|   `-- settings
|-- Sd_Dir
|-- Sd_Error
|-- Sd_FileConvert
|-- Sd_Html
|-- Sd_Image
|-- Sd_Mail
|-- Sd_Net
|-- Sd_Parse
|-- Sd_Session
|-- Sd_Settings
|-- Sd_Template
|-- Sd_User
|-- Sd_Util
|-- Sd_Xslt
|-- conf                       # <-- default configuration
|-- doc                        # <-- documentation
|-- examples
|-- log
|-- resources
|-- templates
|-- test                       # <-- PHPunit testcases
`-- thirdparty                 # <-- thirdparty modules

You may have noticed that there is only one single class file in Sourdough's root directory. Right, that's the global entrypoint for the whole framework. We don't need to care about relative paths and dependencies in between the available packages.

Packages are split into separate subdirectories with the 'Sd_' prefix. All class files are named after the following pattern: 'Sd_ClassName.class.php'.

Some examples of basic usage can be found in the /examples directory. The /test directory contains unit test cases. For usage in your application you might want to delete those two directories.

The /thirdparty directory contains thirdparty modules that have been only changed as far as it was necessary to fit them into Sourdough. Otherwise this is non-Sourdough content and won't be documented here.

Basic Usage

There's not a lot to tell about basic usage. Sourdough contains a default configuration array and as long as you don't need to configure any module, usage is pretty straightforwarded:

// create a new Sourdough framework instance (using default configuration)
$SOURD = new Sourdough();

// get the session object
$Session = $SOURD->Session();

// call a static utility class
$cont = Sd_File::getContent('test.txt');
// another example
$url = Sd_Url::getRequestedUrl();

The only thing you will ever need to include is the global framework class file Sourdough.class.php. If a package needs another object that has not yet been instantiated, it will do it on its own. Also, static utility classes don't need to get included by hand, PHP5's __autoload() takes care of this.


Sourdough always loads its default configuration. You can find it in <sourdough base>/conf/ All of those configuration options can be overridden the first time you load the global Sourdough object. The configuration array you pass is always getting merged with Sourdough's default configuration.

Have a look at the following example how to do it:

$conf = array();
// configure the Sd_Session object
$conf['session'] = array(
    'driver' => 'php',
    'gc_maxlifetime' => 2880
// configure the Sd_Xslt object
$conf['xslt'] = array(
    'force_engine' => true,
    'engine' => 'xalan',
    'xalan_bin' => '/usr/bin/xalan'

// create the global Sourdough object
// and override the above configuration options
$Sourd = new Sourdough($conf);

// get the Xslt and Session objects for usage in your application
$Xslt = $Sourd->Xslt();
$Sess = $Sourd->Session();

If you wish to add or change configuration parameters at a later point in your script, just call $Sourd->loadConfig($newConf). The new configuration parameters will be merged with the existing ones.

For the configuration of your database abstraction layer, please see the sample in Database Abstraction.

Reference Getting Started

Prev. Installation   Database Abstraction Next

Home | Documentation | Download | RSS 1.0 | GEO URL

Driven by coWiki 0.3.4 (Boron) web collaboration tool.