TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 04-06-2009, 08:51 AM   #1 (permalink)
Jim
The Addict
 
Jim's Avatar
 
Join Date: Nov 2007
Location: the Netherlands
Posts: 281
Thanks: 2
Jim is on a distinguished road
Default Framework: Do's and Don'ts

Hi PHP-friends!

It's been a while but I entered a new internship so I'm back :P.

Lately everybody is creating his own Framework, no-one builds websites without them. So with our combined experience we should really know how to create a good framework by now.

Just starting of with something that looks like ZF from the start will only give problems in the end. Before you start creating a framework (or any big project) you have to plan things carefully. This was one of my biggest mistakes. I created a framework which works perfectly fine and stabile, but in the end I wanted it to work differently and even nicer.

My framework runs like this:

Client requests url: /news/32-mymessage.html

index:

- Load Core
- Config
- Initialize a MySQL connection via a Factory->Singleton

core:

- Initialize the main template, start a buffer
- Use reflection to search for a "news" module which uses the IModule interface
- Load the main() function from the module via reflection

module:

- Get content - bla bla not interessting
- Get template via the core and print it with the earlier created content

core:

- Close buffer and paste that in the main template
- Dump the result

This gives a quick example of my framework. I think this works fine, but you will see my problem in the next part: file structure

./index.php
./config.php
./modules/
./modules/modulename/
./modules/modulename/index.php
./template/
./template/templatename/
./template/templatename/modulename/
./template/templatename/modulename/index.tpl
./core/
./core/core.php
./core/lib/
./core/lib/libname.lib.php

As you can see the modules and templates are seperate. I wanted this because I wanted to be able to change the complete layout by assigning a different template and not just the base. But it loses the possibility to just add a new block of functionality by just uploading a folder.

--

Basically I made this topic to exchange ideas about good structures frameworks for your website, so we can learn from eachother.
__________________
Nunchaku! Who doesn't like martial arts? =)
Send a message via MSN to Jim Send a message via Skype™ to Jim
Jim is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:56 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design