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

Smarty 3.0: initial discussion
Goto page Previous  1, 2, 3, ... 10, 11, 12  Next
 
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 -> Smarty Development
View previous topic :: View next topic  
Author Message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Jun 09, 2005 7:21 pm    Post subject: Reply with quote

mohrt wrote:
2) make Smarty 3.x compatible with both PHP4 and PHP5.


no way, I'm afraid.

php4 and php5 aren't compatible if you turn on error_reporting high enough.

if you turn on E_STRICT in php5, parsing of *ALL* your php4-classes will emit error-messages.
if you declare your classes php5-properly to remove those error-message, your classes aren't valid php4-syntax an emit syntax-errors there.
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: Thu Jun 09, 2005 8:03 pm    Post subject: Reply with quote

Well, FWIW, here is my little opinion piece on the PHP4/5 issue...

I think Smarty 2.x already pushes the things you can safely do with PHP4 near to the limit. So the 2.x branch ought be maintained so as to continue to provide support for PHP4 installations. Its a mature and stable project. Its not going anywhere, certainly not away.

If we undertake the effort of a re-design and re-implementation, it makes sense to use PHP5 not because of some pie-in-the-sky marketing ideal but because PHP5 offers facilities and opens techniques not available under PHP4. A new version would be a pretty big effort both in design/implementation and also from a users perspective since the likelyhood of 100% BC is fairly small in my opinion. We might be able to add new features to 2.x but a redesign under PHP4 is fairly much out of the question now that PHP5 is in the wild. A PHP4 redesign is just as likely to break BC as a PHP5 redesign and it would not gain the benefits that PHP5 opens the door to. So that is fairly much a lose-lose proposition. We are better-off just maintaining our current 2.x tree and adding incremental enhancements if any are warranted.

I don't think PHP5 will start getting "big" until 5.1 and perhaps not until 5.5 or 5.6. 5.0.4 is missing several key features or has key bugs in features that would otherwise make it very useful. In 5.1 we will see PDO bundled, a usuable SPL and several bug fixes whch are presently causing strange reference errors and segfaults depending on which constructs are used and how (eg: try blocks are a little tricky at the moment). Pear 1.4 will still not be released for 5.1 but maybe we will get GOTO Smile 5.5 is supposed to be the first release to finally support unicode. I expect versions after 5.1 to be usable, stable and fairly much feature complete.

The upshot is that there is time to build a new version of Smarty before PHP5 adoption becomes more the norm than the exception. I don't doubt that PHP4 will continue to live for a long time yet, but I suspect that once 5.1 is released, the number of projects that target PHP4 for new development will begin to decrease more rapidly than we are currently seeing. Will we have to win the users back? Yes--so we better nail the target right from the start.
Back to top
View user's profile Send private message
iamsure
Smarty Rookie


Joined: 02 Feb 2005
Posts: 22

PostPosted: Fri Jun 10, 2005 3:27 am    Post subject: Reply with quote

[edited]

Last edited by iamsure on Thu Jul 27, 2006 12:40 am; edited 1 time in total
Back to top
View user's profile Send private message
boots
Administrator


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

PostPosted: Fri Jun 10, 2005 4:19 am    Post subject: Reply with quote

iamsure, I'm curious as to why you think it will fork. What does Smarty on PHP4 not currently do that is required and can be reasonably implemented on PHP4? Please give specific suggestions -- I don't think that anyone is against implementing features that are reasonable in 2.x. For myself, as far as PHP4 is concerned (which, BTW is officially in maintenance mode -- meaning critical fixes only) Smarty's current implementation is about as good as I can imagine. In other words, except for incremental changes, I can't think of how to improve it enough to justify a PHP4 rewrite. Just because I can't see it doesn't mean it isn't possible, but specific suggestions are more useful than arm waving. Please consider stability, too. A lot of the developers have good ideas of what the current short-comings are and what can be improved by doing a rewrite; yet even if there was a new PHP4 version of Smarty, as long as it was a complete re-engineering I (for one) would be just as hesitant to upgrade as if it was a new PHP5 version. In other words: don't mess with a stable system unless you are modernizing it. I think I can safely say that PHP4 is not the road to modernity.

On the other hand, I think PHP5 offers several new opportunities that actually warrant a re-think. The timing is out of everyone's hands but I can say this: Monte and many others have made sure that the users in this community have never been treated as second class; I really can't imagine that will ever change and I am saddened to see you say such a thing.

On the topic of timing, we won't see PHP5.1 released until the end of the summer at the earliest. When do you think we should start thinking about it? Ever? Flipping through a recent copy of php|a I notice hosters already providing full 5.0 support. Of course, as you note, adoption won't happen overnight and maybe, just maybe, they never will. Yet if they don't, PHP is surely dead. Again, that's my opinion but it is based on the fact that PHP4 is no longer being developed. All mid to long term bets are on PHP5.

Still, you as you suggest--it may take a year before we start seeing real penetration; however, you did mention something that I would like to take up. You said that PHP5 was released a year ago and still isn't well supported. The reason is simple: everyone is waiting for PHP5.1. That's the one that is supposed to justify the switch. Frankly, the first version of PHP5 that I found tolerable enough to use was 5.0.4 and it still has (minor) rough edges as I already hinted at. Its not that PHP5.0 is bad or full of bugs -- its just that PHP4 is a known quantity and 5.0 was seen as an early adopter version by many. In terms of stability, it turns out that PHP5.0.4 is ready enough for me (there are plenty of posts here that testify to the fact that I didn't have much enthusiasm for PHP5 until the 5.0.4 release). In terms of full adoption, PHP5.1 fits my bill. Of course, if 5.1 turns out to be miserable, I reserve the right to re-evaluate my (personal) position. At the moment, I have no reason to think that PHP5.1 won't deliver. Other than the time it will take to get it through the channels, do you see it as ultimately a failure or a success?

There are other things, that will push PHP5 adoption. I won't bother to list them all but many third party modules won't be maintained and some may never be available (think MySQL5) on PHP4. The picture you are painting is too black-and-white for me. There are pros and cons on both sides.

I should also note that I didn't give any data as you suggested I did. I said right from the start that the post was my opinion on the situation. Moreso, I didn't give a timeframe for when I thought the majority of users will be on PHP5. Frankly, I don't know. I feel that hedging my bet on the latest and greatest is not so hard to do when we already have a solid and stable implementation built on old faithful.

Best regards.


Last edited by boots on Fri Jun 10, 2005 4:55 am; edited 1 time in total
Back to top
View user's profile Send private message
iamsure
Smarty Rookie


Joined: 02 Feb 2005
Posts: 22

PostPosted: Fri Jun 10, 2005 4:54 am    Post subject: Reply with quote

[edited]

Last edited by iamsure on Thu Jul 27, 2006 12:41 am; edited 1 time in total
Back to top
View user's profile Send private message
boots
Administrator


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

PostPosted: Fri Jun 10, 2005 5:05 am    Post subject: Reply with quote

I just want to correct one thing: I am not softening my stance. A PHP4 redesign is out of the question. If that happens, Smarty will be forked: the current code will be the fork and that is what will be maintained.

I would try to respond again but honestly, I have no idea what you mean by making PHP4 users second class. It just doesn't make sense. Smarty 2.x will be supported. You will be as first class as you are now. Where is the problem? No one seems to know how to do a Smarty3 using PHP4. If someone can figure it out, that would be great. In the meantime, I suggest we consider what PHP5 can do for us.

And I apologize if my comments seemed disrespectful. I honestly meant none at all.

Cheers.
Back to top
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Fri Jun 10, 2005 6:45 am    Post subject: Reply with quote

Hi,

tonight i`ve dreamed of a new feature of smarty Smile

What do you think about something could be called "template inheritance".

So Templates could inherit of others and only have to override/add some stuff of the "older" one.

simple example:

table.tpl
[php:1:6000504319]
<table>
{foreach from=$rows item=row varId="ParentLoop"}

<tr>

{foreach from=$row key=key item=field}

<td>{$key} : {$item}</td>

{/foreach}

<tr>

{/foreach}
</table>
[/php:1:6000504319]


specialtable.tpl
[php:1:6000504319]
{ extends file="table.tpl"}

{ override varId="ParentLoop"}

<colgroup>

{foreach from=$colgroup item=col }

<col width={ $item }/>

{/foreach}

</colgroup>

{foreach from=$rows item=row }

<tr>

{foreach from=$row key=key item=field}

<td>{$key} : {$item}</td>

{/foreach}

</tr>

{/foreach}

{/override}
[/php:1:6000504319]

So you can reduce redundant templating

What do you think?

Bye,
Markus
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Jun 10, 2005 1:49 pm    Post subject: Reply with quote

Quote:
What do you think about something could be called "template inheritance".


First thought, no way. This isn't something that belongs in templates. This will just confuse designers (imho). You are better off dynamically including a different template for each loop type if that is what you are trying to achieve.
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Jun 10, 2005 2:37 pm    Post subject: Reply with quote

Quote:
But as I said in previous posts, I'm fantastically happy with Smarty, so beyond general concepts like optimization and modularity, I don't have many suggestions.


Optimization and modularity are the key ingredients to a rewrite. The problem is that PHP4 is just not equipped to handle it, at least not the way I'd like to do it.

I tested rewriting some Smarty code in a better OO fashion (within PHP4's limits), using a separate class inheritance for caching, compiling and debugging. What I came up with? The only thing I gained was when displaying a purely cached page, there was a speed up of about 3x, mostly because of the smaller code footprint. But when it came to compiling a template or displaying an uncached page, this was about 4-6x slower due to all the class inheritance going on.

Running the same code in PHP5 produced nearly no time overhead from the inheritance. Obviously, it has a much better OO model. On top of that, it has features such as autoloaders and property/method overloading, something that can really make optimization and modularization easy. This is just not possible within the limitations of PHP4. Even if emulation in PHP4 was possible, the performance overhead could not be justified.

I don't really see the point about PHP4 users being put second-class, I'm one of them for crying out loud Smile Smarty 2.x will work with PHP4 and be maintained for the forseeable future, at least until PHP4 is a very small fraction of the global userbase. The advantages of moving to PHP5 are too large to be ignored. Although this may have short-term consequences (maintaining two code-bases), the long-term benefits are what we're looking at. Trying to make Smarty 3.x work on PHP4 and PHP5 just cripples the effort.

On the whole PHP 5.0/5.1 thing I have no comment, but just taking a look at history: PHP 4.0 was introduced in July of '99 and 4.1 come out in December of '01 (two and a half years). PHP4 was a major update from PHP3. (Is the update significance the same for PHP4->PHP5?)

Looking that this graph:
http://www.tiobe.com/tpci.htm

The PHP usage soared about the time 4.1 rolled out. Does history repeat itself? Time will tell, but it usually does.
Back to top
View user's profile Send private message Visit poster's website
chidera
Smarty Rookie


Joined: 08 Dec 2004
Posts: 22

PostPosted: Sat Jun 11, 2005 12:01 am    Post subject: Reply with quote

Hi Everyone,

I just wanted to chime in....

I'm one of those guys that's come in fairly late, if you will, to both PHP and Smarty. And although I don't get to work with either as often as I'd like, I'm loving them both! Smile

So, let me get started...

First, I'd like to second a previous poster's request for some way to easily read AND write configuration settings. I'm not sure if such a thing belongs in Smarty or not. But, if there is going to be some support for configuration settings, then I'd suggest it ought to be more complete. (BTW, if anyone knows of a good class/library for reading/writing configuration settings from/to files, please let me know. I've had a difficult time finding one that I like.)

Second, I'd like to talk about PHP5. I agree that writing Smarty 3.0 to support BOTH PHP4 AND PHP5 sounds good, especially when backward compatibility is considered. But -- without any testing to confirm this -- it seems VERY likely that the end result would suffer in terms of speed/optimization....something most/all of us want....speed/optimization, that is.

I have been a proponent of OOP for quite some time. PHP5 makes great strides in this area, and I'd like to take advantage of that in my own development. But, I want to bring Smarty along with me. Smile I see my code improving in many ways once I make the move and I can't imagine anything different for Smarty.

If the majority of people begin using PHP5 in 12 months or so, then it seems like now is a good time for work to begin on Smarty 3.0. I am not sure how long you guys feel it will take to develop -- how long do you think? -- but it seems like a lot of work. And I'm sure that in 12 months there would still be bugs, tweaks, feature requests, enhancements, etc. on the list. So, if I were to decide, I'd say you've already waited too long. Wink

Third, I wanted to talk about feeling like a second-class citizen. Since I started using Smarty, I've ALWAYS felt like a first-class citizen. That's great. But, I also recognize that as development resources are poured into 3.0, there will be fewer resources to support 2.x. But, that's reality.

Now, if there are fewer resources for 2.x, does that mean we're second-class citizens if we don't get the feature we want added or if it takes a *whole* day for a response in the forums? I don't think so. One thing I also recognize is that a better product, one that is moving forward, is being developed and will be in my hands soon. (And several years later, the same thing will happen again when Smarty 4.0 comes out.)

Another thing I realize is that SOMEONE ELSE IS DOING ALL THIS GREAT WORK THAT I BENEFIT FROM FOR *FREE*! That doesn't mean I can't voice my opinion or complain, but it does mean that I need to remember who's sacrificing their time for my benefit.

Some other open source project leaders do NOT ask the community for input. And some make changes without letting anyone know. And whenever there are more than two people involved together, there inevitably comes the point where they disagree on something. There's no way in a community this large that everyone will be happy with the decisions that are made. (Good luck, guys. Wink)

So, "in conclusion".... Wink

I wanted to say that you should have started the Smarty 3.0 development yesterday for PHP5 while doing your best to keep the 2.x users happy. And we users need to recognize that the product may not go where we want it, but we should voice our opinions and expect that the next version of Smarty will be at least as good as the last and that we'll be treated at least as good as before. We have no other reason to believe otherwise, do we?

And, get more complete configuration setting support, as stated earlier....Please. Wink

I haven't taken the time to consider any further suggestions, but I'll let you guys know if I think of any.

Take care,

Travis
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Jun 16, 2005 2:07 pm    Post subject: Reply with quote

Quote:
And, get more complete configuration setting support, as stated earlier....Please.


Explain this a bit... I don't see why writing config file information programatically is so necessary. Config files are meant for static variable values (that template designers have access to) that are usable across all templates, and can also be read from PHP.

IF this was added, it would be a PHP API:

[php:1:b95adc9838]$smarty->write_config('var','val','section');[/php:1:b95adc9838]

NOT something done from within a template.
Back to top
View user's profile Send private message Visit poster's website
chidera
Smarty Rookie


Joined: 08 Dec 2004
Posts: 22

PostPosted: Thu Jun 16, 2005 4:51 pm    Post subject: Reply with quote

Hi,

Thanks for the reply.

No, I wasn't thinking of any config functionality within the templates. I was thinking along the lines of a function of the smarty class like you indicated in your reply.

The template function, config_load, is sufficient for my uses from a template standpoint. But, it would be nice to have a way to administer that config file from a programmatic standpoint.

Like I said, I'm not convinced that a "configuration administration class" (or related functionality) belongs in the smarty class, but it would be nice to have something that all of us could use that helps us to read from and write to the config file. And, it should be aware of the various constraints and rules and such that Smarty's config files must adhere to....

Does that make sense?

One more thing....you stated that "config files are meant for static variable values (that template designers have access to) that are usable across all templates, and can also be read from PHP". That makes sense. But, what if you want to allow template designers access to config files through a "nice interface", then one has to have a way to read from and write to the files.

Again, I don't consider this as something that Smarty is missing. Rather, I consider it something on my list of things that would be nice for my specific needs/wants. Smile

Anyway, that's it. I certainly appreciate your efforts.

Thanks again and take care.

Travis
Back to top
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Sat Jul 09, 2005 5:54 pm    Post subject: Reply with quote

What dou you think about a "global-var-register".

Somethink like:
[php:1:3218733d6a]
//setup smart
// ...
$smart->register_global( 'db', $myDBConnection);
$smart->register_global( 'config', $myConfiguration);
[/php:1:3218733d6a]

this vars can be accessed inside all plugins. (smarty->get_global( 'db')).
So you dont need a global scope e.g. to a database class.

Bye,
Markus
Back to top
View user's profile Send private message
boots
Administrator


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

PostPosted: Sat Jul 09, 2005 11:37 pm    Post subject: Reply with quote

I don't see the point of that since PHP already has a global scope accessible via the $GLOBALS[] superglobal and the global keyword.
Back to top
View user's profile Send private message
ZakMc
Smarty Pro


Joined: 04 Oct 2004
Posts: 182

PostPosted: Fri Jul 15, 2005 2:19 pm    Post subject: Reply with quote

What do u Think about this?

Code:
{include file=`#news_tpl_folder_name#``$news_tpl_name`}


or

Code:
{popup_init src=`#javascript_folder_name#`overlib.js"}


Combine config vars with normal vars.
Back to top
View user's profile Send private message
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 -> Smarty Development All times are GMT
Goto page Previous  1, 2, 3, ... 10, 11, 12  Next
Page 2 of 12

 
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