RE: [SMARTY-DEV] Re: Compiling config files & alternative config files format

From: Date: Tue, 03 Dec 2002 21:16:04 +0000
Subject: RE: [SMARTY-DEV] Re: Compiling config files & alternative config files format
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-368@lists.php.net to get a copy of this message
Rather than compiling the config files directly into the compiled smarty template file, why not compile each config file to its own php file (say... "filename.scfg.php", in the compile_dir), and just include them from the compiled template file, recompiling them first if necessary? To do this, you would just provide a function on the smarty object, $smarty->loadConfig( $filename ). This function would be called from the compiled template when it is time to load a config file (call it as $this->loadConfig( '<filename>' )). The loadConfig function, then would check the timestamp of the config source against the timestamp of the compiled config file (if any), do the recompile if necessary, then include the config file using ( require_once('<compiled-config-filename>') ). I think this would solve the re-compile issue that you've been discussing. You'd still incur the overhead of including a php file, and executing the php source, but you'd bypass the overhead of parsing a text file - which is probably the most time-consuming task. I don't know, but I bet this could be done without breaking the existing interface as well. In addition, the loadConfig function could use a file extension to determine the expected type of the source file, and thus which ConfigCompiler implementation should be used. This decision would only have to be made when a config file required recompile - all compiled configs would look the same to smarty. While you're at it...what do you think about upfitting the config loading process to be capable of using resource plugins? It would be very useful (I think). good luck, -Lee > -----Original Message----- > From: Monte Ohrt [mailto:monte@ispi.net] > Sent: Tuesday, December 03, 2002 9:19 AM > To: bdunogier@wanadoo.fr > Cc: André Rabold; smarty-dev@lists.php.net > Subject: Re: [SMARTY-DEV] Re: Compiling config files & alternative > config files format > > > Compiling the config vars statically could be done, there is just a > level of complexity with recompiling. Currently, only the > timestamp from > the original template is tested. Since config vars can be > used from any > parent or child template, you'd have to track the whole heirarchy of > config files to test if something changed. Smarty's caching > already does > this btw, so use caching when possible. > > Monte > > On Tue, 2002-12-03 at 02:51, Bertrand DUNOGIER wrote: > > AR> not all people do install PHP with expat XML parser and > there are some > > AR> web space providers which don't use it too. So you > would need to implement > > AR> your own XML parser which is definitly too slow > > AR> (http://sourceforge.net/projects/phpxd > > AR> for example is really great). > > AR> I don't think it's a good idea to use XML exclusively > but perhaps as an > > AR> alternative format. > > AR> So the developer could choose if he want's XML or Plaintext. > > Yes, it's what i think too. > > > > Many hosts run expat, and when you run a professionnal > projet, you can choose > > the modules you're using. > > > > Since Config_File.class.php does not look complex, it > might be easy to write an > > alternative config file parser that could load the config > vars from an XML file. > > A SQL datasource could be handy too :) > > > > I'm waiting for a comment from Andrei or Monte regarding > the caching. > > > > Bertrand > -- > Monte Ohrt <monte@ispi.net> > > > -- > Smarty Development Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.smarty.dev (#368) next »