Nice, thanks Iván.

Just another potential pitfall worth mentioning in there, maybe, is the fact that you should be careful when your templates output intermediate files to more than one directory, as the different intermediate files might contain the same function names, which will result in an error being thrown on template execution, since a function cannot be included if it has already been defined.


E.g. if 'first.tpl' template has a code destination of '/tmp/first/' and 'second.tpl' has a code destination of '/tmp/second/', then there is a change of having duplicate function names if your calling script executes templates coming from both directories at the same time.

Kind Regards,
Werner

Iván -DrSlump- Montes wrote:

Please feel free to modify it as you see fit.

PHPTAL for SysAdmins:

PHPTAL functions by generating PHP files from the template's logic,
this means that it needs a directory to store those generated files so
they can be parsed by the PHP interpreter.

By default PHPTAL will use the system's temp directory (via PHP's
sys_get_temp_dir() function if available) or will try to guess where
it should be, /tmp on Unix like systems and c:\windows\temp on
Microsoft ones, to store the compiled templates. The default
destination can be changed to your liking by setting the define
PHPTAL_PHP_CODE_DESTINATION or by calling setPhpCodeDestination()
method with the appropriate path.
Be it the system's temp directory or a custom one, it needs to have
its permissions setup as to allow the PHP running process (the Apache
user if using mod_php or the cgi/fastcgi user otherwise) to create and
update files in that directory.

PHPTAL creates one file for each different template file and one file
for each tag if using phptal:cache. It doesn't create separate files
for macros (which are simply compiled as PHP functions inside the
compiled template file).
These files are automatically cleaned up once in a while, more
specifically, each time a template is compiled there is random
probability, controlled by setCachePurgeFrequency() method, which will
just delete files older than set by setCacheLifetime() method.
Alternatively you can also schedulle the deletion of old/unused files
by running this from an Unix like shell (like in a cron job):

   find /tmp/ -name tpl_\* \( -atime +1 -o -mtime +14 \) -exec rm -v {} \;



Ivan
------------------------------------------------------------------------

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to