Configuring Sodapop

The Sodapop framework consists of two parts:

  1. The /sodapop_framework directory that contains the framework files. This directory lives outside the web server's document root.
  2. The application directories, of which there is one for for each application. These contain all of the models, views, controllers, etc. for the particular applications, as well as a /www directory that serves as the document root for the web server.

Installing Sodapop

Sodapop works well on PHP 5.3; earlier versions may require some now-standard extensions to be installed. Additionally, it is recommended that production environments have the PHP APC extension installed as it can be used to cache some system calls across requests and will make the framework faster.

Below are the detailed directions on how to install the framework.

  1. Download the framework. Extract it to a directory accessible to your web server, but outside of any virtual host's document root.
  2. Create a directory for your application. This should also be accessible to your web server, but outside of any virtual host's document root.
  3. Copy the contents of the /sodapop_framework/skeleton directory into your new application directory.
  4. Point the document root for your desired hostname to the /www directory inside your application. If you are using Apache, you can find instructions here.
  5. Edit the file /www/.htaccess file. Locate the line for include_path and set the correct path to the /sodapop_framework directory. This is the one that has the /Sodapop and /skeleton directories in it.
  6. Edit the file /conf/sodapop.json and set your database and hostname settings to the correct values. If you don't need a database, remove the entries from the file.
  7. Open you browser and go to your domain. You should see a success message.
  8. You're all set. Start building your application!

The Five Important Files

The Application's index.php

Within each application's /www directory there is an index.php file. This file serves as the bootstrap for the framework. It is typically rather short. By default it contains:

There is also a config setting you can set to show PHP's error messages, but the commented lines can be uncommented to capture errors during the bootstrap.

.htaccess

Sodapop requires Apache's mod_rewrite module to be enabled in order to use its routing system, and the /www/.htaccess file is required to route requests into index.php. The default file is:

Of note is the line that starts with php_value include_path. The colon-separated list of directories contains the path to the Sodapop framework root, the application's models directory and the application's library directory, which is typically where 3rd party libraries are installed. The paths are relative to the location of .htaccess. Each of these must be present and correct for the framework to function properly.

mime.ini

The final required file in /www, mime.ini contains a list of file extensions and their associated MIME types. This file is rarely used and is simply a fallback in case PHP's fileinfo extension can't be found or can't be used to properly figure out a particular file's MIME type. Outside of exceptional circumstances it will not need to change.

sodapop.json

Located in the application's /conf directory, the config file is required to exist but can be blank if nothing needs to be set. It is documented fully on the sodapop.json page.

routes.json

Located in the application's /conf directory, the routes config file is required to exist but can be blank if nothing needs to be set. It is documented fully on the routes.json page.