On Mon, 2003-09-29 at 15:22, Chris wrote: > I am working on a fairly large scale (for myself anyway) project using PHP > and MySQL. I am victim of teaching myself to program, not separating > presentation from my code-- all the things that lead to masses of spaghetti > code so atrocious even I can't figure out what I was doing an hour ago. > > I'm not looking for an IDE or code generator so much as some practical > advice for organization and framework when developing a larger app. I know > of PHP Fusebox, having programmed with Cold Fusion fusebox for a while, but > it seems like that might be too much. Maybe I just need a sensical, > practical approach to application layout. What do you all do? How can I > learn to be a better PHP programmer in this regard?
I use InterJinn (yes I know I wrote it :). Personally I never liked how smarty did things, still smells like code embedded in the templates. InterJinn uses a tag based templating system, which is extremely easy to add your own custom tags to easily make use of complex functionality. unlike Smarty InterJinn doesn't load the templating system when you load a page, since it compiles the templates and content files directly to the page you will request. Only a tiny overhead occurs on each page load to check file timestamps for newer versions. If a newer dependency exists, then, and only then is the templating system loaded to updated the requested page. Some people will tell you not to use a non-PHP include() /require() templating. My best guess is that they're uneducated *start the flames*. In the case of InterJinn PHP native includes can't beat it, since it does the include at compilations, such that at run time there is no include to be done. Tags are easier to read than oodles of PHP code since the tag name is often sufficient to state its purpose. Contrast: include_once( 'header.php' ) versus: <myProject:header/> Or better yet for a multilingual site (probably nto even on your mind): if( $lang == 'fr' ) { include_once( 'header.fr.php' ); } else { include_once( 'header.en.php' ); } versus: <myProject:header/> InterJinn also comes with modular designed core services for managing things like session data, caches, database, properties, forms, etc. Databases are used via names you provide. For instance you configure all your sites database connections in one place similar ot the following: $GLOBALS['interJinn']['database'] = array ( 'myProject' => array ( 'host' => 'some.host.com', 'login' => 'mememe', 'password' => 'YES' 'database' => 'myProject', ), 'myRelatedProject' => array ( 'host' => 'some.host.com', 'login' => 'mememe', 'password' => 'YES' 'database' => 'oldProject', ), 'default' => 'myProject' ); Then you can access your database in your components as follows: $dbManager = $this->getService( 'dbManager' ); $db = $dbManager->do->getConnection( 'myProject' ); $db->do->query( 'SELECT data1, data2, FROM someTable' ); Then if you change your database settings changing the settings requires changing one location. Also since core aspects of the framework can be replaced with your own cooked versions, you can add to the database API to log queries, or anything else, and without ever touching the official distribution code. Just extend the class, then register the new Core API. Then when you upgrade you don't need to worry about any changes you've made. Anyways there are many, many reasons to use a framework, and I'm obviously biased with respect to my own, but even if you don't choose InterJinn I think you will gain a lot from the use of any of the myriad of available templating and application frameworks that are available. Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php