mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Apr 29, 2003 4:32 pm Post subject: Testimony from M Bueche (March 23, 2003) |
|
|
First it needs to be said, Smarty does not work for all aplications. It makes
no sense to add another layer of logic to our system. However, I am currently
working on a very large PHP project that involves many different applications
integrated into a web portal. And let me says this:
I started the project out using simple templating like includes, functions to
generate Style sheets, etc. and it worked fine. However, I found myself in this
predicament. My scripts were getting very long, 7-8K lines and it was becomming
more and more difficult to debug my applications because so much presentation
logic was embedded into my business logic. (for example print statements,
formatting of strings with HTML, et.)
I decided to try the Smarty system and I can honestly say, after a bunch of
scrating my head and getting frustrated, it was the BEST move that we ever
made. Now, I removed all of my presentation logic out of the business logic,
less rabit trails with all the includes and html output functions. (I mean
really, ask yourself, how many functions/classes have you written just to wrap
your data in HTML. Well, smarty has already written all of those functions and
given you so much flexability. Now, my business logic scripts are 2-3K and then
all the HTML is separated out into template files. Now, if the designer wants
to play with the UI, he just plays with the templates and my business logic is
unaffected.
Also, I think that you are all forgetting that while yes, smarty adds another
layer of complexity, it makes up for that with comiling and caching. Let's say
that you run a site that has a news column, or a BBS and the data may only
change a few times daily, but you have tens, hundreds, or even thousands of
users visiting your site. With caching anc compiling, you scripts do not have
to be interpreted every time a user visits your site, only when there are
changes. This takes load off of your DB server, web server, etc. It is the
equivalent of writing out HTML files and then serving those up to your users.
VERY COOL, I personally have notice a HUGE increase in speed on our site (2-3K
user visits per day).
So, I'll wrap back to my original point, can you do what smarty does using your
own PHP templating system? Of course, but why, the smarty team has already done
the work for you and added the cool features like comiling anc caching. Not
only that, remember, smarty is written 100% in PHP, so it is not like another
loanguage, it just like using a library of classes/functions.
Embrace it for medium to large sites, it may no be worth the effort for some of
you on your small projects, but I can say that I have been converted and I will
use it on every project.
Lastly, let me also leave you with another example of how smarty has made my
like 10X easier. I was contracted to design a content management system for a
local company with the caviat that the company wanted to custom design the UI
for every customer. Meaning the engine of the CMS would not change only the
templates. With smarty all I had to do was write the engine in PHP and then all
the deigners had to do was come up with the new templates. Then for each
customer, there was 1 universal engine, one that I would keep up to date and
free of bugs. AWESOME.
Hope this helps ... |
|