Open-Source PHP Framework - Designed for rapid development of performance-oriented scalable applications

.config file

API >> config

Vork Configuration

All Vork configuration settings are in the .config file (except for the flag to enable/disable debug mode at the top of /webroot/vork.) All settings are optional, but may be required for your application. Vork can operate even with the .config file removed, but will be in a limited-functionality mode.

Settings that are required for most applications

date_default_timezone_set

At the very beginning of the file you will want to your timezone, the default is EST. The acceptable TZ values are very flexible and can be reviewed at php.net.

SITE_NAME and SITE_DOMAIN constants

Set this to the name of your site and the domain name (without the www.), the value is used as the default page title in the default layout, as the default domain part of the return address in the forgotPassword() method in the account component and in other default templates provided with Vork. If you will not use any default-provided Vork features then these constants will never get used.

Application-specific constants

You can set any application-specific constant or variable at the bottom of the config class and access it anywhere in your application. Eg.:
const MY_CONSTANT 'Hello, Shalom and Bonjour';
 public 
$myProperty = array(123);


Access them from any MVC element via:
get::$config->MY_CONSTANT
 get
::$config->myProperty

DB_NAME constant

Enter the name of your database schema. This is the name that you set when you originally created the database with the create database myNewDatabase (not the name of your database product like MySQL/Oracle/etc.) SQLite users can enter the filename here.

dbConnect() - set your database connection

To enable a database, find the line: self::$db = new $db('HOSTNAME''USERNAME''PASSWORD'self::DB_NAME); and change the hostname, username and password to those of your database credentials. In most setups hostname is either "localhost" or set to an IP address.
The arguments sent to the $db() function match the syntax of the PHP connection method of the interface for your database. The default of hostname, username, password will work for MySQL and most others so long as your database is using the default connection settings, eg. for MySQL the default port and socket, if not, just add the parameters in the syntax of your database interface constructor method.
Eg. for MySQL:
$db($host$username$passwd$dbname$port$socket)

Other databases with object-oriented PHP connections

For other databases that have object-oriented PHP connections you will need to look up the __construct() method on php.net and send the arguments that the database expects to the __construct() (the connect method.)
Eg. for SQLite:
self::$db = new $db('FILENAME');
Then in the .config-rdbms file, change mysqliabstract (appears in two places near the top of .config-rdbms) to the abstract class that extends the PHP extension of your database, eg.:
require '../sql/sqlite3abstract';
 class 
db extends sqlite3abstract {

If there is no abstract class for your database and the DB has an object-oriented PHP connection you can create a connection abstract using the /sql/sqlite3abstract file as a template.

Databases with only the legacy procedural PHP extension

For databases that only have the legacy procedural PHP extension your connect method must match the Vork DB object-oriented interface to your database:
PostgreSQL
$db($host$username$password$dbname$connectType null)
Oracle (works with 8i and newer)
$db($username$password$dbname null$persistent true$charset null$sessionMode null)
MS SQL
$db($host$username$password$dbname null$persistent true$newLink null)
IBM DB2
$db($username$password$dbname$options null)
Sybase
$db($host$username$password$dbname null$persistent true$charset null$appname null$new null)
For all other databases with only a procedural PHP extension you will need to create a way to access the database in object-oriented fashion, it is fairly easy using one of the existing DB object-oriented interfaces as a template.
Note, these interfaces will not add any overhead as traditional DB abstraction layers would, these only remap the legacy naming convention and function-access to object-oriented camel cap style.
Next open the .config-rdbms file and change mysqliabstract (appears in two places at the top of .config-rdbms) to the name of your database (in all lowercase letters,) eg.:
require '../sql/oracle';
 class 
db extends oracle {

Application-specific settings

APP_CONSTRUCT constant

Set this to a file name that is in the root of the mvc directory and Vork will execute the file before before every page in your application loads

APP_DESTRUCT constant

Same as APP_CONSTRUCT but executes after each page in your Vork application completes

ajaxEnabled property

Enables special AJAX handling - eg.: AJAX requests will skip the layout file and just return the view contents
Valid values:
(Boolean) true or false will enable or disable AJAX in all controllers
array('controlerName1' => true, //enables AJAX for actions in controlerName1
      'controlerName2' => 'actionName', //enables AJAX for the single action of controlerName2 only
      'controlerName3' => array('action1''action2')) //enables action1 & 2 for controlerName3
Can be set globally here and then overridden form within any controller-action or component via:
get::$config->ajaxEnabled[mvc::$controller] = false; //can be true, false, the actionName or an array of actionNames
FYI: If you will be defining which actions to AJAX-enable then you will need to include the "index" action if you want that to be AJAX enabled as well.
For more granular control over what gets returned via AJAX you can use (Boolean) is::ajax() from anywhere in your application to differentiate incoming AJAX requests from regular HTTP requests.

SHARE_THIS constant

Set this to your ShareThis ID to use the helper to create ShareThis boxes

ADD_THIS constant

Set this to your AddThis ID to use the helper to create AddThis boxes

GOOGLE_AD_CLIENT constant

Set this to your AdSense client ID to use the helper to show AdSense units

GOOGLE_CHECKOUT property

Enter your Google Checkout credentials to use the helper to send users to a Google Checkout page

AUTHNET_LOGIN and AUTHNET_PASSWORD constants

Enter your AuthorizeNet credentials to enable use of the chargeAuthNet method of the cc component

UPS property

Enter your UPS account credentials and XML Access Key (refer to ups.com for signup) to enable use of the UPS functions in the shipping component

AMAZON property

Enter your Amazon Web Services ID, access key and secret key to enable use of the amazon component

PAYPAL_EMAIL constant

Enter your PayPal email address to enable use of the PayPal component

isSuperuser() method

Convenience function to determine if a user is a "superuser" (someone who gets complete access to all information) and by default only used in the errors view (to determine verbosity) but typical applications find many uses for this, eg.:
$enablePageEdit get::$config->isSuperuser();

Setting up multiple database connections

If you will need more than one database connection in your application then you need to go to the top of the .config and uncomment the line:
public static $db$dbro$modelObjects = array('db''dbro');
as well as the line:
const DBRO_NAME 'slave4readonly';
and also uncomment in the dbConnect() method:
self::$dbro = new $db('HOSTNAME''USERNAME''PASSWORD'self::DBRO_NAME);
then change all FIVE locations of dbro to the name that you choose for your additional database connection (if your connection is for a read-only database you may choose to just leave this as dbro)
You can now access your new connection from any model via $this->dbro (or whatever you changed the name to) the same way you would the primary database $this->db

Eric DavidLast modified by Eric David