Pluf : PHP 5 Framework   Download | Bug Tracking | Source | Documentation | Forum | Latest Changes | Home

Configuration Settings

Configuration Access in your Application

Using the static method Pluf::f('configuration_key') you can access the configuration keys defined in your configuration file.

This method accepts a second parameter to be used as default parameter. You must use it wisely to avoid the need of a configuration in the default case. For example:

$time_zone = Pluf::f('time_zone', 'Europe/Berlin');

This will default to 'Europe/Berlin' if not defined in the configuration file. The default configuration keys of Pluf are listed here. Your applications are free to add new ones, but if possible always try to use the default configuration variables when you can.

If your application uses the prefix MyApp for all its classes, by convention, your specific configuration variables should have the prefix myapp_.

Configuration File

The configuration file of an application is passed to the Pluf::start method in the entry point (the index.php file) of your application.

The file must return an associative array of configuration values. For readability, you should write it like that:

<?php
$cfg = array();
$cfg['debug'] = true;
$cfg['time_zone'] = 'Europe/Berlin';
return $cfg;

In all your PHP files, you should not include a trailing ?> at the end of the file.

Configuration Settings

debug (false)

Enable debug information or not. Do not use it in production!

time_zone ('Europe/Berlin')

Time zone for the application, you can pick up another one using the list available on the PHP website.

encoding ('UTF-8')

You should not change it.

installed_apps (array())

List of installed applications.

db_get_connection ('Pluf_DB_getConnection')

Function to get a DB connection resource, you can customize it to have per model connection.

pear_path ('/usr/share/php/')

The classes in PEAR are not all PHP5 compliant, by providing the path the error handler can ignore the non fatal errors coming from the PEAR classes.

db_engine

The database engine used. This can be SQLite, MySQL or PostgreSQL. The name is case sensitive.

db_server

The database server, not used for the SQLite engine.

db_database

The database, this is the full path to the database file in the case of the SQLite engine.

When creating the SQLite database with the command line tools and then using it with Apache, you need to be sure that the database is writable for the Apache process.

db_login

The login to access the database server, not used for the SQLite engine.

db_password

The password to access the database server, not used for the SQLite engine.

db_table_prefix

If you want to have multiple installations within the same database, you can add a prefix for the créations of the tables.

db_version

For the moment, used only for the MySQL driver to handle the case of the pre 4.1 versions which were not able to handle the UTF-8 encoding correctly.

upload_url

upload_path ('/tmp')

middleware_classes (array())

pluf_use_rowpermission (false)

If you want to use row level permissions in the permission system. Most of the application require that but it as a small overhead when getting the permissions for a user (1 SQL query) and when dropping a user or a group (1 SQL query).

mimetype ('text/html')

Default mime type for the answers.

cookie_path ('/')

Cookie path.

cookie_domain (null)

It will use the current domain.

cookie_secure (false)

Give access to the cookies only for a SSL link.

cookie_httponly (true)

Create HTTP only cookies. By forcing HTTP only cookies, a range of XSS exploits can be avoided. Change that only if you know what you are doing.

session_cookie_id ('sessionid')

Sessions are using a cookie, this is the name of the cookie.

login_view ('login_view')

The name of your login view.

admins (array())

Admins. Admins are notified by email when an error occures on a production server.

Example:

array(
      array('Admin', 'admin@example.com'),
     );

mail_backend ('mail')

How to send the emails, by default using the builtin mail function of PHP. Pluf is using the PEAR Mail package in the background.

You can pass the parameters you want to the Mail::factory() method by setting the parameters as defined in the Mail::factory definition with the addition of the mail_ prefix. This is to avoid a conflict with the other configuration variables.

For example, if you are using the smtp backend and want to set the timeout to 60 seconds, just add the following in your config file:

$cfg['mail_timeout'] = 60;

send_emails (true)

If you set to false, emails will not be sent, this can be practical during unit testing. You can also use fakemail for email testing.

secret_key

This is critical configuration variable. You need to set it to a unique long string for each installation.

template_folders

An array of path to folders where the template engine will find the templates. The order in the list matters, the engine will stop at the first template found.

tmp_folder

Temporary folder where the compiled templates are stored together with all the dynamically cached data. This folder must be writeable by your Apache process.

template_tags (array())

List of extra template tags. For example:

$cfg['template_tags'] = array(
      'hotkey' => 'IDF_Template_HotKey',
      'issuetext' => 'IDF_Template_IssueComment',
                              );

This gives access to 2 new tags hotkey and issuetext in the templates.

template_modifiers (array())

List of extra template modifiers. For example:

$cfg['template_modifiers'] = array(
      'size' => 'IDF_Views_Source_PrettySize',
      'markdown' => 'IDF_Template_Markdown_filter',
                               );

Here you will be able to use for example {$file.size|size} in your templates.

template_context_processors (array())

If you are using a request context object as a context for your templates, you can preprocess automatically the context to add variables.

last_update_file (false)

If you are using the media tag, you can use a last update file which modification timestamp will be used to happen a unique string at the end of the file. This allows you, for example, to force user agent to reload the latest version of your css style sheets.

simple_test_path (false)

Path to your simple test installation if you are using the unit testing framework (yes, you should perform unit tests!).

Report issues in the documentation

If you find errors or issues in the documentation, report a bug. We will update the documentation accordingly.

Pluf © 2005-2008 Loïc d'Anterroches, supported by Céondo Ltd.