MFHJoe Posted March 17, 2007 Share Posted March 17, 2007 Hi, I'm thinking about starting off a simple PHP framework using OOP which I can use in my applications. I want the structure to be something like this: - index.php (uses the framework) - framework - core.php (decides which framework files to include and grabs the config) - library - errors.php (the error handler) - database.php (the database handler) - forms.php (the form handler) - config - defaults.php (holds the default config) - config.php (hold the user-defined config) The thing is, I need everything to link in with each other, ie. I need to use the error class on it's own, as well as in the database handler and the form handler. All files also need to be able to use the config. Early tests show that I can't do this. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/43152-making-a-framework/ Share on other sites More sharing options...
ignace Posted March 18, 2007 Share Posted March 18, 2007 are you using flowcharts and UML-diagrams? Because besides that, i think its quite neat! Quote Link to comment https://forums.phpfreaks.com/topic/43152-making-a-framework/#findComment-210015 Share on other sites More sharing options...
cmgmyr Posted March 18, 2007 Share Posted March 18, 2007 you might want to include all of the related files into one file, so it might be a little to manage...I don't know if you should do this in framework, but I would think it would be ok. For example: library.php <?php include "errors.php"; include "database.php"; include "forms.php"; ?> so now you can just call library.php if you need any one of those 3 pages. Quote Link to comment https://forums.phpfreaks.com/topic/43152-making-a-framework/#findComment-210119 Share on other sites More sharing options...
Liquid Fire Posted April 11, 2007 Share Posted April 11, 2007 you could also use the __autoload function of PHP. This would be more ideal becuase if you start to have 5, 10, 15, so on class files, loading them all everytime when you just need one would slow the script down becuase the with above idea, it would have to load everything instead of just the 1 file you need. also this way you will not have to worry about including those class file since they will be included automatically. Quote Link to comment https://forums.phpfreaks.com/topic/43152-making-a-framework/#findComment-227072 Share on other sites More sharing options...
Nameless12 Posted April 19, 2007 Share Posted April 19, 2007 autoload is bad for performance so I would not use it for loading the framework as frameworks should try to be as efficient as possible. But that said autoload should be fine for loading the app built with the framework. Also spl_autoload_register is better for framework design in my opinion to __autoload as you can do something like spl_autoload_register(array($this, 'autoload')); Quote Link to comment https://forums.phpfreaks.com/topic/43152-making-a-framework/#findComment-233489 Share on other sites More sharing options...
jchemie Posted April 21, 2007 Share Posted April 21, 2007 Well, I would recommend you read about autoloading of classes from php.net comments in classes and objects section there are a lot of good scripts to help you do the same. You could also just make up the config class that holds up the config data and use it. Quote Link to comment https://forums.phpfreaks.com/topic/43152-making-a-framework/#findComment-234892 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.