Инструменты пользователя

Инструменты сайта


limb2:en:settings

Limb configuration settings

Configuration settings

Limb uses 2 ways to store its configuration stuff:

  1. via PHP constants
  2. via *.ini files

PHP constants

In our opinion constants are the most natural and flexible way to declare some global configuration parameters. Usually Limb uses constants to define directories, DB settings and some important global settings(like enabling debug console, debug of templates etc).

All constants must be defined in PROJECT_DIR/setup.php which in turn includes LIMB_DIR/setup.php. However you can «override» these settings in setup.override.php script which is included first(if it exists in the same directory) by all setup.php scripts(actually there's no real constants overriding, the trick is that it's included before other constants declaration).

It's much easier to show rather trying to explain, here's an example of some project setup.php:

<?php
 
if (file_exists(dirname(__FILE__) . '/setup.override.php'))
  include_once(dirname(__FILE__) . '/setup.override.php');
 
@define('FOO', 'foo'); //please note @, we're supressing possible notice errors with it
[...other constants...]
?>

Now if include setup.php somewhere in the code FOO constant will be equal to 'foo'.

And here comes setup.override.php:

<?php
 
define('FOO', 'bar');
 
?>

Now if include setup.php now the FOO constant will be equal to 'bar'.

This technique let's you «re-define» only neccessary settings without the need of editing setup.php. Furthermore it makes sense to ignore setup.override.php with CVS since these overriding settings are pretty unique.

By default setup.php contains pretty general settings and usually all you have to do is to override some DB stuff and directories. We provide nicely commented setup.override.php-example with every Limb based project, you can use it as a template for constants overriding.

*.ini files

Limb is also capable of using settings stored in *.ini files. These files should reside in PROJECT_DIR/core/settings or LIMB_DIR/core/settings.

You shouldn't be editing *.ini files stored in LIMB_DIR/settings, instead you want to override them with equivalents in PROJECT_DIR/settings. This project component overriding technique is used for almost every Limb conception.

Ini files are perfect for storing lots of configuration stuff since Limb provides convenient tools for accessing them. Ini files are compiled into PHP files, this way the parsing overhead is minimal.

Here's an example of such a file:

#ini supports comments like this one
#ini values can be global 
value = 1
#... and ini values can be grouped 
[FOO]
value = 2    
#you can have simple non-indexed arrays
foo[] = 1
foo[] = 2
foo[] = 3
#..and you can have indexed arrays
foo[yo] = 1  
foo[wo] = 2  
#here comes another group of values
[BAR]
bar[] = 1  

Since 2.3.1+ you can also override certain ini files(remember setup.override.php?). Thus config.override.ini will be used instead of config.ini if it exists in the same folder.

Tips&tricks

Force template compilation every time

Every project has config.ini file in PROJECT_DIR/core/settings directory.

By default it contains only one valuable parameter:

force_compile = 1

This parameter forces the WACT template engine to recompile the template every time it is requested, this is useful for development. For speed purposes on production environments you will definitely want it to be set to 0.

Console debug mode

If you'd like to have a peek into Limb execution internals you you'd definitely want to see Limb debug console which can be enabled with DEBUG_CONSOLE_ENABLED constant e.g:

define('DEBUG_CONSOLE_ENABLED', true);

Template debug mode

If you need more information about template structure of you page you can use magic DEBUG_TEMPLATE_ENABLED constant. If this constant is set to TRUE template system will output the template name and a small link to edit this template (the whole template or just a part of it). Use TEMPLATE_EDITOR_PATH constant to set a path to your .html editor, e.g:

define('DEBUG_TEMPLATE_ENABLED', true);
define('TEMPLATE_EDITOR_PATH', 'jedit.bat %s'); 

Note: Works only for IE!

Обсуждение

Ваш комментарий. Вики-синтаксис разрешён:
   __    ___    __ __   ____  ____ 
  / /   / _ \  / //_/  / __/ / __ \
 / /__ / // / / ,<    / _/  / /_/ /
/____//____/ /_/|_|  /_/    \___\_\
 
limb2/en/settings.txt · Последние изменения: 2010/11/10 10:02 (внешнее изменение)