In essence, configuration templates are PHP files which, when executed,
output web server configuration files. The templates are executed in the
environment where the specific variables $VAR
and $OPT
are
available.
$VAR
is an object containing the data model which should be applied
to a template. The variable contains an essential set of parameters
defining the content of web server configuration. The detailed structure
of the array is presented in the Appendix C.
The most important function is IncludeTemplate() which is part of the
$VAR
array. The function allows including templates one into
another, and it is defined as
IncludeTemplate($templateName, $OPT, $metainfo)
where
-
$templateName
- string denoting name of included template.
Required -
$OPT
- an associative array which passes values to a template.
Optional -
$metainfo
- an associative array which defines certain aliases in
the template context. Optional
The basic function usage is as follows:
## source: default/server.php
<?php echo $VAR->includeTemplate('server/tomcat.php') ?>
A text generated by the included template (server/tomcat.php
) will
be included in the configuration file.
In cases when the text generated by an included template should depend
on the context, for example, when iterating over a set of values, it is
possible to pass additional parameters to the template.
## source: default/server.php
<?php echo $VAR->includeTemplate('service/php.php', array<span…