Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Store compiled templates in DB

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
Stormtrooper
Smarty Rookie


Joined: 26 Feb 2004
Posts: 6
Location: Silver Spring, MD

PostPosted: Mon Mar 22, 2004 8:14 pm    Post subject: Store compiled templates in DB Reply with quote

I've looked around for related threads on this topic and looked through the docs but there's nothing that I can find that matches what I'm looking for. The closest match is the 'Register Resource' documentation pages.

I'm looking for a way to be able to store the compiled templates into a DB (mysql specifically). I am not doing this in hopes that it would be faster, I realize that there would be no speed advantage over using plain text files for compiled templates.

The reasoning for this is ease of use for users/clients using my software. One of the main disadvantages of storing the compiled templates in files is the webserver needs the proper permissions to write the file. This is a major drawback in my case. In my support forums the main issue users come across is a 'smarty error' saying it can not write a temporary file or template (always due to the web server not having proper permissions)

If the smarty API would allow for new methods like register_compiled_resource, I could provide the functionality to do this. But I simply do not see a way to do this with the current version of smarty.

If someone has another idea regarding this, I'm all ears. Thanks.
_________________
Jason Morriss
http://www.psychostats.com/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Mar 22, 2004 9:04 pm    Post subject: Reply with quote

You are correct: it is not feasible.

The big issue (other than the expected drastic speed crunch) is that compiled templates are eventually PHP included (not read and eval'd). You will note that this implies that PHP op-caches (accelerators -- like PHPA, APC, Turck MMCache, etc) are able to cache compiled scripts.

You may be able to hobble a solution using a custom PHP stream wrapper which was capable of reading/writing from a db instead of the filesystem. You would then adjust the appropriate places in Smarty where compiled files are written or included (eg: core/core.write_compiled_resource.php) and add the stream prefix that you wrote to the filename. I think it is too much effort and that the overall performance is going to be rather disappointing.

IMHO, if you can't permission on the filesystem, Smarty may not be a suitable choice. So I must ask: why is permissioning such an issue? In many cases, you can avoid that issue by having the webserver create the needed temporary directories instead of having the user create them. That way they are owned by the process that requires them (the webserver).

FWIW, this has come up before: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=502
Back to top
View user's profile Send private message
Stormtrooper
Smarty Rookie


Joined: 26 Feb 2004
Posts: 6
Location: Silver Spring, MD

PostPosted: Tue Mar 23, 2004 2:19 pm    Post subject: Reply with quote

Thank you, boots. I like Smarty's design and simple use. So I'll stick with it regardless of my little issue. I never considered the OP code caching that accelerators are able to do with how it's setup now.

The reason permissioning the filesystem is annoying is because a lot of the users of my software do not know have the proper knowledge to run a webserver, much less be able to understand what permissions to set and where.

In the end, I believe all my issues will be worked out by providing ample documentation Smile.

Thanks again. And I'll take a look at that other thread you provided.
_________________
Jason Morriss
http://www.psychostats.com/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP