I want to get some input from experienced PHP developers on how to structure code.
I feel my applications soon get “dirty” and unorganized.
Should I start coding in OO? Should I start using MVC? What about design patterns? What other options are there? How can I organize and structure my application code better (beyond proper indentation and naming)?
Links to resources are welcomed 🙂
If I decide to start coding using MVC? Should I use any frameworks or just hand code everything?
What is your suggestion.
Instead of worrying about creating something from scratch, I would start by using a framework and extend it with your own widgets. Zend Framework is excellent and has a massive community of support: http://framework.zend.com/
Otherwise, the best book so far I’ve found about PHP design is called ‘Advanced PHP Programming’ by George Schlossnagle. It explains patterns and design efficiently better than anywhere else I’ve seen.
As per comments below, I definitely don’t mean to say that you should only learn a framework. It’s never good to learn only a framework, but you can learn coding techniques through other peoples’ code, like in frameworks/libraries/etc. Attack your learning through every source available (forums, books, code resources) and make an educated decision as to the approach you should be using when taking on a new project.