By rick888
via rawseo.com
Published: Oct 22 2009 / 09:03
A good list of php tools.
By rick888
via rawseo.com
Published: Oct 22 2009 / 09:03
Comments
SeanJA replied ago:
Smarty is not a must have tool. In fact, it is a must avoid tool.
Justin Silverton replied ago:
"Smarty is not a must have tool. In fact, it is a must avoid tool."
I disagree. What problems do you have with smarty?
I have used it on many projects and it has worked out very well. It allows you to separate all of your php code from designers/people that just want to make some html changes. It also has built-in caching, which makes it fast.
SeanJA replied ago:
I have a problem with almost all of Smarty... The caching is nice I guess, but not worth all of the extra hassle that Smarty provides:
No proper syntax highlighting (there are some editors that do it sort of kind of mostly...)
It uses (by default) { and } causing all kinds of havoc if you have to embed some css or html (not that I do that a lot)
New syntax for common things that are already part of php
It is, however not a complete implementation of php, so trying to do certain things does not work
The array syntax is horrible, and sometimes you can use [ ], but most of the time you will use .
By default functions in smarty do not accept a whole array (which is because of the way that it was written, yes there is $array|@function)
The syntax to call a function is backwards from that of php: {$var|function}
Unless you are in an if statement: function($var)
If statements fail when you write them the way that you would normally in php: {if($something)} should be {if $something}
The 'section' loop
No while loop
No switch
The compiled php files that come out of smarty are worse than useless
As are the error messages (because they reference the compiled file rather than the template)
var in shorthand and value is in long hand in the assign function: {assign var=something value='some value'}
...
and so on and so forth...
Justin Silverton replied ago:
I have a problem with almost all of Smarty... The caching is nice I guess, but not worth all of the extra hassle that Smarty provides:
"No proper syntax highlighting (there are some editors that do it sort of kind of mostly...)"
I don't think of it as a programming language. I use it as a template language, which works well with designers since they can open up the template files in a regular html editor.
"It uses (by default) { and } causing all kinds of havoc if you have to embed some css or html (not that I do that a lot)"
Surround all offending code with {literal}{/literal} and it will fix this issue.
"New syntax for common things that are already part of php"
This may be true, but I think it makes it easier for designers.
"It is, however not a complete implementation of php, so trying to do certain things does not work
The array syntax is horrible, and sometimes you can use [ ], but most of the time you will use .
By default functions in smarty do not accept a whole array (which is because of the way that it was written, yes there is $array|@function)
The syntax to call a function is backwards from that of php: {$var|function}
Unless you are in an if statement: function($var)
If statements fail when you write them the way that you would normally in php: {if($something)} should be {if $something}"
To each his own. I don't have problems with this syntax.
SeanJA replied ago:
"I don't think of it as a programming language. I use it as a template language, which works well with designers since they can open up the template files in a regular html editor. "
The problem is that it has most of the constructs of a programming language, so programmers end up using it as a programming language causing all sorts of horrible code in the templates. Which is not easier for the designers.
"This may be true, but I think it makes it easier for designers. "
The designers that I know have found it harder, because they have to now learn 2 extra languages php and smarty just to be able to modify the templates.
"Surround all offending code with {literal}{/literal} and it will fix this issue. "
I know that, but that is just something they added to solve a problem that they created. Also, since javascript uses the {} syntax for objects you have to comment it out so it becomes: /*{literal}*/ /*{/literal}*/ just so that your syntax highlighter does not mistake it for javascript.
Causing things like this:
just so you can tell if the problem lies in your javascript code while you are writing it.
Justin Silverton replied ago:
okay, what do you use instead of smarty?
SeanJA replied ago:
php, since it is a template language already.
Justin Silverton replied ago:
"php, since it is a template language already."
I figured this much from your previous comments. Every project I have worked on (many open source and many non-open source) that had no template language used (smarty..or anything else) was a complete nightmare to maintain.
You really should be using some sort of a templating engine...for the sake of the people that have to look at your code after you leave.
SeanJA replied ago:
You can make an unmaintainable mess out of any templating language (engine). From what I have had to deal with, it seems that Smarty makes it easier when you don't know what you are doing.
Justin Silverton replied ago:
"You can make an unmaintainable mess out of any templating language (engine). From what I have had to deal with, it seems that Smarty makes it easier when you don't know what you are doing."
I find it funny that you mention that people that use smarty "don't know what they are doing". You essentially have to learn another syntax and language, which takes more skill than just intermixing php and html.
Show me an example of an html page, which has php and html mixed, that you think looks good (easy for a designer to read and easy to maintain in the future).
SeanJA replied ago:
I did not say that, I said if you don't know what you are doing Smarty makes it way easier to screw things up.
I think that this code is quite clean:
http://github.com/SeanJA/ShoestringPHP/blob/master/application/views/header.php
http://github.com/SeanJA/ShoestringPHP/blob/master/application/views/users/login.php
http://github.com/SeanJA/ShoestringPHP/blob/master/application/views/footer.php
Justin Silverton replied ago:
Oh, and your example above? You could solve this issue by putting your Javascript code in separate files. It's better to do this for maintainability (you won't be able to re-use it without duplicating it) and the browser won't cache it (which will load faster if cached).
SeanJA replied ago:
I realise that, but if other javascript code (or css) has been dropped into a template file and it uses variables that are only available in the template file, or because someone was too lazy to write a separate js file 4 years ago and it has been that way (and growing larger since then).
Justin Silverton replied ago:
I know what you mean. I have had to work with legacy code like this and it's frustrating.
SeanJA replied ago:
---- doh
Christopher Strosser replied ago:
A little more effort could have gone into this... there are already too many "articles" w/ hundreds of "must-have" tools.
If it were my list, I would have limited it to the products I *REALLY* believe in... Eclipse PDT, FileZilla, PuTTY, OpenOffice, phpMyAdmin, Zend Framework, Crimson/Emerald Editor (simple, but powerful, not being actively developed), cPanel for server administration, WAMP or Zend Server for Windows development/staging... memcached, APC, or eAccelerator for caching.
....and so on and so forth.
Voters For This Link (13)
Voters Against This Link (5)