How to set up a configuration file for the Stanford Web Application Toolkit

From Web Services Wiki

Revision as of 18:22, 3 December 2008 by Mrmarco (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Problem

You want to create or modify a configuration file for SWAT.

Solution

The toolkit accepts a YAML-formatted configuration file with the following attributes:

---
 
# StanfordApp YAML configuration file
 
info:
 
  # Basic application info
 
  name: My Application
  admin email: nobody@stanford.edu
  admin name: Admin Name
  base url: http://www.stanford.edu/group/my_group/my_app/
  base directory: /afs/ir.stanford.edu/group/my_group/my_app/
 
database:
 
  # Login credentials
 
  name: db_name
  username: db_username
  password: db_password
 
  # Use encryption for all database operations?  Enter 'yes' or 'no'
 
  # yes => All database traffic is encrypted, slower but more secure.
  # no => Just the login credentials are encrypted, faster, most commonly used.
 
  use encryption: no
 
  # Use MySQL-based sessions?  Highly recommended if using sessions and MySQL access is enabled.  Enter 'yes' or 'no'
  # The toolkit will create a table called "php_sessions" for you if it doesn't already exist.
 
  use mysql sessions: yes
 
settings:
 
  # Undo magic quotes?  Recommended setting is 'yes.'
 
  undo magic quotes: yes
 
  # Logging mode: available options are production, development, or debugging
 
  # production => recommended for live sites; does not display errors, warnings, or notices to the browser
  # development => recommended for sites currently being developed; shows all errors and warnings but not notices
  # debugging => useful for debugging; shows all errors, warnings, and notices
 
  logging mode: development

Simply create the configuration file and send its path as an argument to StanfordApp.

// Include StanfordApp
include_once("stanford.app.php");
 
// Create a new StanfordApp with a configuration file
$app = new StanfordApp("/path/to/config.yaml");
Personal tools