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

Thinking Smarty as a MVC framework assistant

 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Wed Apr 08, 2009 5:27 pm    Post subject: Thinking Smarty as a MVC framework assistant Reply with quote

I am now thinking Smarty as a tool to build a small framework system. Here is how I am planing my new developments:

Smarty holds a basic handling of templates and its resurces (plugins: functions, modifiers, etc...). But I am thinking to hold make take out ALL application logic into a separate directory called models. All the templates are now the views of MVC pattern. This is a work in progress and I will try to publish my work online, once I complete it.

One main logic goes with .htaccess which identifies each of the requests. It breaks each page requests into models part and views parts. For example, if /user/login.php is accessed, it should break into user and login.

Now, the framework starts searching for user class and its login method. If they exist, it tries to execute them. Plus, it searches for some other models, (in this case: includes files in models/user/login.php).

Finally, it determines to display the template file (smarty_templates/user/login.php).

The user and login behave as independent class/method and model/view pairs. Further, php5 feature allows to call ANY class name though __autoload() function, and the complete set is a perfect gem for Smarty.

The major benift now onwards is that, I am now, free to write any page call, and its template, even though a physical (real) file does not exist where a hacker may guess. Ultimately, breaking the user reuqests, searching for class, function, models and Smarty template are big and main issues.

I will be sharing more of my experience once I complete it. Thanks for all!
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: Wed Apr 08, 2009 6:57 pm    Post subject: Reply with quote

I have a simple MVC at tinymvc.com. You can adapt Smarty as the view pretty easily.
Back to top
View user's profile Send private message Visit poster's website
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Thu Apr 09, 2009 4:55 pm    Post subject: Tiny MVC is great. Reply with quote

There are a lot of expert and matured MVCs. I have also downloaded your mvc and looing into it. It looks really tiny, and just useful upto the features I want.

I do not prefer other MVCs for now, and so, will try to add your work/logic. When I started, I did not mean to write an MVC, but I was a bit tired of adding a lot of configurations in each files, and I search some way out. In fact, I am just writing a very small class file to split up the user requests (urls) and send that to Smarty for views, after some works with the models. But, Smarty is one of the core thing for me. So, the total size seems bigger. This is a work in progress.

TinyMVC looks to become a total collection of 51kb of files - thats impressive, and readable in a shorter period of time. Thanks for your work. And, I liked the page's layout (clean, bluish).
Back to top
View user's profile Send private message 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 -> Tips and Tricks 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