update docs

This commit is contained in:
mohrt
2002-02-19 22:40:49 +00:00
parent c6b1c7f6bd
commit 65a6165f3d
10 changed files with 88 additions and 60 deletions

24
BUGS
View File

@@ -1,11 +1,17 @@
There are no known bugs with Smarty, although there are some bugs in PHP that
cause problems with Smarty. preg_replace() had a parameter added in 4.0.2 that
is needed for Smarty. preg_grep() previous to 4.0.4 has a bug which Smarty has
a built-in workaround for. PHP 4.0.4 has a bug with user callbacks which would
cause this syntax in Smarty to crash PHP: {$varname|@modname} Use PHP 4.0.4pl1
to fix this, or avoid using the "@" with modifiers. if you are passing variables
to {include} statements, you will need PHP 4.0.4 or later, which requires the
use of get_defined_vars() function. Some versions of Windows 2k have a problem
with flock(). Comment out the flock() command in _write_file to get around this.
There are some bugs in older versions of PHP that cause problems with Smarty.
preg_replace() had a parameter added in 4.0.2 that is needed for Smarty.
preg_grep() previous to 4.0.4 has a bug which Smarty has a built-in workaround
for. PHP 4.0.4 has a bug with user callbacks which would cause this syntax in
Smarty to crash PHP: {$varname|@modname} Use PHP 4.0.4pl1 to fix this, or avoid
using the "@" with modifiers. if you are passing variables to {include}
statements, you will need PHP 4.0.4 or later, which requires the use of
get_defined_vars() function. Some versions of Windows 2k have a problem with
flock(). Comment out the flock() command in _write_file to get around this.
To be absolutely safe, use 4.0.4pl or later with Smarty.
Smarty versions previous to 2.0 require the PEAR libraries. Be sure to include
the path to the PEAR libraries in your php include_path. Config_file.class.php
uses the PEAR library for its error handling routines. PEAR comes with the PHP
distribution. Unix users check /usr/local/lib/php, windows users check
C:/php/pear.

41
FAQ
View File

@@ -72,18 +72,19 @@ A: Smarty reads the template files and creates PHP scripts from them. Once
know of their existance. (NOTE: you can turn off this compile checking step
in Smarty for increased performance.)
Q: Why can't I just use APC <http://apc.communityconnect.com/> (or Zend Cache)?
A: You certainly can. Smarty's cache and these cache solutions have nothing in
common. What APC does is caches compiled bytecode of your PHP scripts in
shared memory or in a file. This speeds up server response and saves the
compilation step. Smarty creates PHP scripts (which APC will cache nicely)
and also has it's own internal caching mechanism for the output of the
template contents. For example, if you have a template that requires several
database queries, Smarty can cache this output, saving the need to call the
database every time. APC cannot help you here. Smarty and APC (or Zend
Cache) actually complement each other nicely. If performance is of the
utmost importance, we would recommend using one of these with any PHP
application, using Smarty or not.
Q: Why can't I just use PHPA (http://php-accelerator.co.uk) or Zend Cache?
A: You certainly can, and we highly recommend it! What PHPA does is caches
compiled bytecode of your PHP scripts in shared memory or in a file. This
speeds up server response and saves the compilation step. Smarty creates PHP
scripts, which PHPA will cache nicely. Now, Smarty's built-in cache is
something completely different. It caches the _output_ of the template
contents. For example, if you have a template that requires several database
queries, Smarty can cache this output, saving the need to call the database
every time. Smarty and PHPA (or Zend Cache) complement each other nicely. If
performance is of the utmost importance, we would recommend using one of
these with any PHP application, using Smarty or not. As you can see in the
benchmarks, Smartys performance _really_ excels in combination with a PHP
accelerator.
Q: Why does Smarty have a built in cache? Wouldn't it be better to handle this
in a separate class?
@@ -96,16 +97,12 @@ A: Smarty's caching functionality is tightly integrated with the template
depending on URL, cookies, etc.
Q: Is Smarty faster than <insert other PHP template engine>?
A: It could be. One of the strengths of Smarty is that it does not need to
parse the template files on every hit to the server. Version 1.3.1 has
many noticable performance tune-ups, so your best bet is to try some
benchmarks and compare for yourself.
The above comparison assumes that you are not using Smarty's built-in
ability to cache templates. If you are, that makes this comparison pretty
unfair since Smarty will basically be displaying static content instead of
generating templates, which will really speed things up especially for
complicated tests.
A: See the benchmark page for some performance comparisons. Smarty's approach
to templates is a bit different from some languages: it compiles templates
into PHP scripts instead of parsing them on each invocation. This usually
results in great performance gains, especially with complex templates.
Coupled with the built-in caching of Smarty templates, the performance is
outstanding.
Q: How can I be sure to get the best performance from Smarty?
A: Be sure you set $compile_check=false once your templates are initially

26
INSTALL
View File

@@ -1,22 +1,24 @@
REQUIREMENTS:
Smarty requires PHP 4.0.4pl1 or later to fix all known problems Smarty has with
PHP. Smarty was developed and tested with 4.0.4pl1. See the BUGS file for more
info.
PHP. Smarty was developed and tested with PHP versions >= 4.0.4pl1. See the
BUGS file for more info.
INSTALLATION:
* copy the Smarty.class.php, Smarty.addons.php, Smarty_Compile.class.php and
Config_File.class.php scripts to a directory that is in your PHP include_path,
or set the SMARTY_DIR constant and put your class files in this directory.
* copy the Smarty.class.php, Smarty.addons.php, Smarty_Compile.class.php
Config_File.class.php scripts and the plugins directory to a directory that
is in your PHP include_path, or set the SMARTY_DIR constant and put your
class files in this directory.
* create a "templates" directory, "configs" directory and a "templates_c"
directory, be sure to set the appropriate directory settings in Smarty for
them. If they are located in the same directory as your application, they
shouldn't need to be modified. Be sure the "templates_c" directory is
writable by your web server user (usually nobody). chown nobody:nobody
templates_c; chmod 700 templates_c You can also chmod 777 this directory, but
be aware of security issues for multi-user systems.
* create a "templates", "configs", and a "templates_c" directory,
be sure to set the appropriate directory settings in Smarty for them. If they
are located in the same directory as your application, they shouldn't need to
be modified. Be sure the "templates_c" directory is writable by your web
server user (usually nobody). chown nobody:nobody templates_c; chmod 700
templates_c You can also chmod 777 this directory, but be aware of security
issues for multi-user systems. If you are using Smarty's built-in caching,
create a "cache" directory and also chown nobody:nobody.
* setup your php and template files. A good working example is included to get
you started. Also see the QUICKSTART guide for some more examples.

View File

@@ -14,12 +14,12 @@ INSTALLATION
------------
Unpack the Smarty tarball. You will see four class files: Smarty.class.php,
Smarty.addons.php, Smarty_Compiler.class.php and Config_File.class.php. You
will need to have all four of these files somewhere in your PHP include path,
so when you call require("Smarty.class.php") from within your application, it
can find the class. Alternatively, you can set the SMARTY_DIR constant in your
application, and Smarty will use that directory as the path to the Smarty
class files. Be sure the path ends with a slash!
Smarty.addons.php, Smarty_Compiler.class.php and Config_File.class.php and a
"plugins" directory. You will need to have all four of these files somewhere in
your PHP include path, so when you call require("Smarty.class.php") from within
your application, it can find the class. Alternatively, you can set the
SMARTY_DIR constant in your application, and Smarty will use that directory as
the path to the Smarty class files. Be sure the path ends with a slash!
Now change directories somewhere inside of your web server document root. For
this guide, we'll create a directory under the document root named "Smarty",

2
README
View File

@@ -2,7 +2,7 @@ NAME:
Smarty - the PHP compiling template engine
VERSION: 1.5.2
VERSION: 2.0
AUTHORS:

View File

@@ -1,10 +1,34 @@
2.0
---
This release removes PEAR dependency -- it was mainly a consequence of using
Config_File class which was originally written with PEAR in mind but was
never integrated into it.
This release is a huge milestone for Smarty. Most notable new things are a
plugin architecture, PEAR dependancies removed and optimizations that
drastically improved the performance of Smarty in most cases.
The plugin architecture allows modifiers, custom functions, compiler functions,
prefilters, postfilters, resources an insert functions all to be added by
simply dropping a file into the plugins directory. Once dropped in, they are
automatically registered by the template engine. This makes user-contributed
plugins easy to manage, as well as the internal workings of Smarty easy to
control and customize. This new architecture depends on the __FILE__ constant,
which contains the full path to the executing script. Some older versions of
PHP incorrectly gave the script name and not the full filesystem path. Be sure
your version of PHP populates __FILE__ correctly. If you use custom template
resource functions, the format of these changed with the plugin architecture.
Be sure to update your functions accordingly. See the template resource section
of the documentation.
The PEAR dependancy was removed from Smarty. The Config_File class that comes
with Smarty was actually what needed PEAR for error handling which Smarty didn't
use, but now everything is self-contained.
Performance improvements are graphed on the benchmark page, you will see that
overall performance has been sped up by as much as 80% in some cases.
Smarty-cached pages now support If-Modified-Since headers, meaning that if a
cached template page has not changed since the last request, a "304 Not
Modified" header will be sent instead of resending the same page. This is
disabled by default, change the setting of $cache_modified_check.
1.5.2
-----

View File

@@ -1,5 +1,5 @@
Smarty Resources on the Web:
(if you have something to add, e-mail monte@ispi.net)
(if you have something to add, e-mail monte at ispi dot net)
Home Page:
http://www.phpinsider.com/php/code/Smarty
@@ -13,4 +13,3 @@ http://www.mapledesign.co.uk/coding/smarty_table.php
Misc:
http://freshmeat.net/projects/smarty/
http://www.hotscripts.com/Detailed/8817.html

View File

@@ -96,7 +96,7 @@ class Smarty
var $cache_handler_func = null; // function used for cached content. this is
// an alternative to using the built-in file
// based caching.
var $check_if_modified = false; // respect If-Modified-Since headers on cached content
var $cache_modified_check = false; // respect If-Modified-Since headers on cached content
var $default_template_handler_func = ''; // function to handle missing templates
@@ -515,7 +515,7 @@ class Smarty
$_smarty_results .= $this->_generate_debug_output();
}
if ($this->check_if_modified) {
if ($this->cache_modified_check) {
global $HTTP_IF_MODIFIED_SINCE;
$last_modified_date = substr($HTTP_IF_MODIFIED_SINCE, 0, strpos($HTTP_IF_MODIFIED_SINCE, 'GMT') + 3);
$gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT';

View File

@@ -2118,7 +2118,7 @@ email: zaphod@slartibartfast.com&lt;br&gt;
{$smarty} variable can be used to refer to 'section' and
'foreach' loop properties. See docs for
<link linkend="builtin.functions.section">section</link> and
<link linkend="builtin.function.foreach">foreach</link>.
<link linkend="builtin.functions.foreach">foreach</link>.
</para>
</sect3>

View File

@@ -96,7 +96,7 @@ class Smarty
var $cache_handler_func = null; // function used for cached content. this is
// an alternative to using the built-in file
// based caching.
var $check_if_modified = false; // respect If-Modified-Since headers on cached content
var $cache_modified_check = false; // respect If-Modified-Since headers on cached content
var $default_template_handler_func = ''; // function to handle missing templates
@@ -515,7 +515,7 @@ class Smarty
$_smarty_results .= $this->_generate_debug_output();
}
if ($this->check_if_modified) {
if ($this->cache_modified_check) {
global $HTTP_IF_MODIFIED_SINCE;
$last_modified_date = substr($HTTP_IF_MODIFIED_SINCE, 0, strpos($HTTP_IF_MODIFIED_SINCE, 'GMT') + 3);
$gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT';