Solar Directory Structure
Something unique about Solar as opposed to other web frameworks is its
directory structure. At first it might seem a little overwhelming and at
first you will probably be confused as to where everything goes. Rest
assured that it will become familiar and you will appreciate the organization
once you get an initial grasp on the layout. This section will go into further
detail about the Solar directory structure to help you figure out where your
Models, Views, Controllers, public assets(javascript, images, css) all go. So
lets get started!
Base level directories
Here is a top level view of the Solar directory structure
trunk/
config/ # config files
docroot/ # web server document root
docs/ # system documentation
include/ # used as the php include_path
script/ # command-line scripts
source/ # source packages, libraries, etc
sqlite/ # sqlite files
tests/ # system test files
tmp/ # temp files
cache/ # private cache
log/ # log files
session/ # session files
Source
The source directory is where all your library files and SVN externals are placed.
This is not used as the include-path; it is a holding location to keep all your
source code in a single location. You could also download and extract PEAR-style
packages here instead of using pear install on them. The source directory is
organized like this:
package, and the organizational structure of PEAR
-- Given an application called 'Footprints' and an additional vendor 'GoogleAPI' --
source/ # source packages, libraries, etc
google-api/ # svn:externals http://example.com/svn/trunk/
GoogleApi/
script/
docs/
tests/
footprints/ # libraries from the system vendor
Footprints/
script/
docs/
tests/
solar/ # svn:externals http://solarphp.com/svn/trunk/
Solar.php
Solar/
script/
docs/
tests/
Include
The include directory contains only symlinks to the source directory.
The include directory is used as the include-path. This means you can have any
files at all in the source directory and not pollute your include-path.
The include directory would be organized like this:
-- Given our 'Footprints' app and addtional 'GoogleApi' vendor --
include/ # use as the php include_path
GoogleApi/ # ln -s ../source/google-api/GoogleApi
Footprints/ # ln -s ../source/footprints/Footprints
Solar.php # ln -s ../source/solar/Solar.php
Solar/ # ln -s ../source/solar/Solar
Config
Next, we have the config directory. This holds all vendor specific configuration/support
files, such as an access.txt file. Note that the Solar config file (config.php) is located
at the base system level.
config/ # config/support files
access.txt # sample vendor access file
Docroot
The last of the "big four" directories is the docroot.
This is the web server document root for the system.
It would be organized as follows:
-- Give our 'Footprints' app and additional 'GoogleApi' vendor --
docroot/ # web server document root
index.php # bootstrap file
public/ # public assets
GoogleApi/ # ln -s ../../source/google-api/GoogleApi/App/Public
Footprints/ # ln -s ../../source/footprints/Footprints/App/Public
Solar/ # ln -s ../../source/solar/Solar/App/Public
Note that in your environment you want Solar sitting outside of the document root.
For example, if you have a web server where the document root is /web/html_docs
your Solar directories would be at the /web/ level and you would place the contents
of the docroot/ folder into /web/html_docs or if you wish, point
your web server to the appropriate /web/docroot folder as the document root.
Bootstrap (Index) File
Because of the standardized system structure, the index.php file knows where everything is for the system.
In theory, you should be able to use the same index file code in any system, and leave the specifics of
setup in the config file. The index file (located in the docroot/ folder) is set up
something like this:
// system trunk directory
$system = dirname(dirname(__FILE__));
// set the include-path
set_include_path("$system/include");
// load and start Solar with the config file
require_once 'Solar.php';
Solar::start("$system/config/Solar.config.php");
// instantiate and run the front controller
$front = Solar::factory('Solar_Controller_Front');
$front->display();
// Done!
Solar::stop();