Ninjakreborn Posted July 28, 2009 Share Posted July 28, 2009 After writing programs for awhile with a specific language you pick up a lot of misc code that you use for various purposes. I originally used a framework structure which was customized. Which happened to be Codeignitor. After awhile though I noticed some projects are better with code ignitor, some are better with cakephp, some are better with symphony, and sometimes even others are best for a given situation. Not to mention if I am working on a 1 page app...something very simple I generally just attach it to a class and do it without a framework. However I noticed throughout all of this (both with and without a framework) over time I end up using a lot of various code that could be easily ported to standard functions for all purposes. I am thinking of the best way to "carry" these around. I could just create me a standard class. And make ti a large class. It would be setup with all of my functions within the class and I could port them everywhere (the 1 page projects, or in mass applications that need frameworks I could still put it in as a custom calss and have all of my custom functions as well as the stuff that comes with that specific framework. So..I am thinking of the best way to set this up. I could either have: 1) A class that is one class that has all of my things in it (all of my functions). 2) A master class/loader that I use and carry around a folder of classes that contain myfunctions split up by category. Then I can instantiate my master class and load my sub-classes as needed for various use purposes (without having to load all my functions on any one project). Then if I need to use my list of classes for a third party framework I can easily attach my master class into teh framework and use it to load all of my sub-classes into the framework system (or I can build a way to auto-load all the classes when I need them to all auto-load). How do you carry your stuff around? This isn't just applicable for PHP. I noticed in C++ as well there are times when you have custom functions that are modifiable and easily imported into general functions. These as well are not always available in third party classes or in the default C++ classes. This is also applicable in ASP, and ASP.net (with C#). So..this is more of general theory and less PHP specific. Also as a note, I noticed the new icons associated with phpfreaks.com, some of those are nice. Quote Link to comment https://forums.phpfreaks.com/topic/167831-general-questionsphp-your-personal-experiences/ Share on other sites More sharing options...
corbin Posted July 28, 2009 Share Posted July 28, 2009 Why not have individual classes? #1 would be terribly bloated. #2 Why not just keep your classes separate and use __autoload or something? Quote Link to comment https://forums.phpfreaks.com/topic/167831-general-questionsphp-your-personal-experiences/#findComment-885242 Share on other sites More sharing options...
gizmola Posted July 28, 2009 Share Posted July 28, 2009 I agree with Corbin -- each class should have its own file if you follow the pear/zend framework guidelines. You could package these by putting them in a directory structure. Take a look at what Zend framework did, because that's a great example of a framework that was also designed to be used as a library ala/carte. Quote Link to comment https://forums.phpfreaks.com/topic/167831-general-questionsphp-your-personal-experiences/#findComment-885252 Share on other sites More sharing options...
Ninjakreborn Posted July 29, 2009 Author Share Posted July 29, 2009 That's more of what I was planning on. Setting up different files for different classes, then having an auto-loader and/or loader class so I can load the ones I want. I will take a look at zend. That's one of the only frameworks so far I haven't really "used" so I will install it and take a look to see how it's structured for research purposes. Quote Link to comment https://forums.phpfreaks.com/topic/167831-general-questionsphp-your-personal-experiences/#findComment-885571 Share on other sites More sharing options...
corbin Posted July 29, 2009 Share Posted July 29, 2009 I think a catch all factory (guessing that's what you mean by loader class) is a bad idea. Quote Link to comment https://forums.phpfreaks.com/topic/167831-general-questionsphp-your-personal-experiences/#findComment-885626 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.