Framework: Do's and Don'ts
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
- Load Core
- Initialize a MySQL connection via a Factory->Singleton
- 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
- Get content - bla bla not interessting
- Get template via the core and print it with the earlier created content
- 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
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.
What is your take on ZF? do you think it is bloated?
Weve looked into going into a framework driven structure, currently we have something mixed between an MVC structure and our own creativity :S
We have 1 core controller, 4 core classes and a library of sub classes, the core initiates the system and the core classes which contain security, database, error, presentation.
Our initiation process is as follows:
1. Error Handling
So each core class would be dependent on all the core classes that would be initiated before it.
Our file structure is as follows:
It is a PHP5 OOP strict framework fully integrated with jQuery
Jim, do I understand your post right when you say you use Reflection in a production ready application for NON-debugging? That is a performance killer my friend :)
Oh? I learned about using Reflection for plugin/module systems in the book ProPHP: http://www.amazon.com/Pro-PHP-Patter.../dp/1590598199
It works like a charm though. But you still sugest I should try another way? (shouldn't be too much work I guess)
well what are you using Reflection for? Code examples?
I use it to locate and validate a module:
maybe it is faster to use the php functions class_exists, class_implements and method_exists
but I havent test that ... here my idea. Note I havent test this code.
|All times are GMT. The time now is 08:32 AM.|
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0