Flourish PHP Unframework

Getting Started

Since Flourish isnt a framework, getting started might seem a little daunting. Lets start with getting the Flourish code and setting up our pages to include it.

Downloading Flourish

As a first step, download flourish and extract it into a directory on your server. To help ensure that a server misconfiguration wont expose your PHP (possibly including database credentials), it is best to try and place your includes outside of the document root.


Set Up an Init Script

At the beginning of every page we arent going to want to include every class file or configuration file, so a logical first step is to create an initialization script to handle that. I prefer to create the script at:


Inside of init.php, put:

include($_SERVER['DOCUMENT_ROOT'] . '/../inc/config.php');

Create a Configuration Script

For better separation, I prefer to put all configuration code into a separate file from the initialization code. I put all of my configuration code in:


Inside of config.php we will put our auto-loading function:

 * Automatically includes classes
 * @throws Exception
 * @param  string $class_name  Name of the class to load
 * @return void
function __autoload($class_name)
	// Customize this to your root Flourish directory
	$flourish_root = $_SERVER['DOCUMENT_ROOT'] . '/../inc/flourish/';
	$file = $flourish_root . $class_name . '.php';

	if (file_exists($file)) {
		include $file;
	throw new Exception('The class ' . $class_name . ' could not be loaded');

Performance tip: If you are running Flourish on a server that has APC, eAccelerator, Turck MMCache or XCache check out the section about class loading.

Start Using Flourish

Now that we have our init script setup, we can start creating pages and using Flourish. Just add this snippet to the top of each of your pages:

include_once($_SERVER['DOCUMENT_ROOT'] . '/../inc/init.php');

Alternatively if you run Apache and have access to the Apache conf file, you can use PHPs auto_prepend_file setting with the Apache PHP settings directives.

Next Steps

If you havent read it already, the How Do I ? page is a good resource for exploring some of the functionality of Flourish. The documentation includes links to detailed information about each class, class APIs and general documentation.

The Flourish Demo Site is a good way to dive into some code to see how Flourish can be used.

For a simpler more guided introduction to Flourish, try checking out the following classes:

The documentation below includes some topics that most PHP developers should know or learn about: