Aro Posted February 16, 2010 Share Posted February 16, 2010 When doing large projects my code seems to get all over the place. How do you guys organize your code? Link to comment https://forums.phpfreaks.com/topic/192211-what-do-you-think-is-the-best-way-to-organize-your-code/ Share on other sites More sharing options...
freakstyle Posted February 17, 2010 Share Posted February 17, 2010 Outside of using a framework I follow some simple rules. /_includes This holds all scripts that should not be accessed directly from your browser, ie your library code base, header files, footers, search scripts, helpers, etc... /javascript /css No other directory exists unless it's an actual page. In my includes i have things like: /_includes/elements -> inline elements, like a photo gallery /_includes/helpers -> procedural and OO files, typically procedural will be in one file OO is one class per file. /_includes/models -> data access classes /_includes/controllers -> scripts to process form actions /_includes/forms -> html forms /_includes/third-party -> code base brought in for specific tasks. There's no right or wrong answer, just be consistent across your projects and find what works best for you. Link to comment https://forums.phpfreaks.com/topic/192211-what-do-you-think-is-the-best-way-to-organize-your-code/#findComment-1013478 Share on other sites More sharing options...
zeodragonzord Posted March 15, 2010 Share Posted March 15, 2010 That's correct, there is no right way. However, the most common organizational structure I've seen is to have: javascript css includes I use JavaScript libraries that I download online, jQuery, Spry, etc. I like to have a folder for each version. I do this so I can keep each version separate from each other in case I need to upgrade. /javascript/spry/spry_version1/ /javascript/spry/spry_version2/ If I update my own files, I won't create new folders for versions. I'll just let Subversion take care of versioning at that point. Link to comment https://forums.phpfreaks.com/topic/192211-what-do-you-think-is-the-best-way-to-organize-your-code/#findComment-1026492 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.