I'm a web development intern working on a small PHP application (just a few pages with a little database access) which has fast become a couple of very non-DRY, non-OO, individual scripts.

A framework seems like overkill (maybe not?) but I was wondering what some best practices for code / folder structure and general solo, small-scale PHP development. What is your starting point for a small application such as this?

  • you should use a MVC framework.
    – pandu
    Aug 1 '12 at 14:24
  • 2
    MVC framework will be an overkill for simple php application.
    – Yusubov
    Aug 1 '12 at 14:38
  • 2
    IMO, the only truly correct answer "just don't do it." While it's possible to work around PHP's lousy design to produce things that work (yes, quite well in a few cases) it's roughly equivalent to pushing an egg with your nose to get it from one place to another -- cute as a party game, but completely insane as a method of transportation. Aug 1 '12 at 14:57
  • 3
    Framework...probably not. Live the mantra, first get it working, then make it beautiful. Just don't let them know it works yet or the ugly will be what you are stuck with ;)
    – Rig
    Aug 1 '12 at 15:27
  • I second @Rig. After flailing with your homegrown solution, you'll better understand the value of a framework. Your understanding will be reinforced from first-hand experience, not second-hand StackOverflow advice.
    – emallove
    Mar 21 '18 at 15:00

The thing about "small" projects is they rarely stay small. If they're successful they grow. Otherwise they die. What happens is you add "just one more little thing" until eventually you have implemented a framework anyway, and it's usually poorly designed because it was never intended to grow.

Even if you are convinced this time is different and your application won't grow, there are so many things you get for free with a framework that I have a hard time seeing why anyone would forgo it. You get themes, user authentication and roles, administration pages, tested modules, security fixes, and more, all of better quality than an individual developer starting from scratch could produce.

Yes, there's a learning curve associated with any framework, which is why people think they're saving time by starting from scratch. That notion is very short-sighted. It's ridiculous to assume that learning a heavily used and tested software application is harder than implementing one of your own from scratch. They have already encountered and solved hundreds of problems that you aren't even yet aware exist.


Did you try using thinga like Silex, micro-framework from Sensio Labs?

There are number of other practices on code organization, and framework usage that you may find helpful:


Well my advice for you is to use MVC and a PHP framework.

This will let you focus more on developing the application itself rather than the basic setting up of the project structure.

I use Zend framework and it's great. The only drawback is its steep learning curve and awkward documentation. However, it has the biggest library of classes I have ever seen.

If you feel intimidated by the complexity of Zend framework then you can try CodeIgniter which has the best documentation out there in addition to many video tutorials. These tutorials got me to understand MVC in action.

When you get comfortable with it maybe you can move to a more full stack framework such as Symfony or CakePHP.


Some will argue that frameworks such as Zend, Symfony and CakePHP are overkill for a simple application, but it all depends on goal. If you just wanna build the application fast and dirty make some scripts and it will work fine.

However, if you really want to learn good OO design practices and deep knowledge from some of the top frameworks out there the go for the kill :)


For small scale PHP development you can use MVC framework. It will allow you to have your codes and folders organized. One of which is CodeIgniter. They have good manual which is also included when you download their framework and they have a much bigger community.

But if you want to make your own framework you can try this folder structure.

lib/ == contains your classes
app/view == contains the templates
app/model == contains the business logics
app/controler/ == contains the implementations of the business logics
config/ == site configurations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.