Php – Does it make sense to avoid a framework when building a large webapp with PHP

frameworksPHPweb-development

Being a PHP web application developer for several years now, I've had my share of MVCs and frameworks. At first I thought they were the best thing since sliced bread; everything seemed to be very easy to implement.

Now however, it seems that the more complex the application gets, the more hassle the framework introduces, so I have to develop workarounds to overcome them. Such workarounds are usually pretty daunting and complex since I have to delve down into the framework core code and make changes so that it behaves the way I want.

For example, in one of my projects where I use Slim(C)+Idiorm(M)+Twig(V) (which I believe is very flexible), I have to create a custom function just to display dynamic data in parent templates; without a framework I could have simply executed mysql_query() in the included file.

Okay, frameworks are cool if I'm creating a simple company profile website; I can just whip some code in one night and they're usually ready by the morning, and the amount of good coding practice and design patterns I've learned from them is very valuable.

But really, for a complex web application like an all-in-one web based school management system, frameworks usually get in the way of my business process like in the example above.

So my question is: is it okay to just go back to basics, and use standard PHP code and libaries for doing my next project where there might be a gazillion frameworks and libraries, provided I can sufficiently use good coding practices and follow sensible design patterns like MVC? My development team is pretty small: only 2 programmers and 1 designer. The other programmer agrees with my thoughts above.

Best Answer

My experience is pretty much the opposite of yours. When doing small, quick things, a framework can "get in the way" a bit as you need to lay out your code in a certain way and think about things carefully before proceeding. By just jumping straight to mysql_query you can have your prototype up and running much quicker.

But for large, complex sites, carefully laying out code and really thinking about how you write your code is extremely important if you want a site that will be maintainable going forward.

In particular, adding mysql_query calls to random parts of the page cycle are generally a really bad idea. You might have one here and one there to begin with and it's no big deal, but before long you'd got dozen spread all over the place and you're wondering why your pages take 3 seconds just to render. Or you change your schema and seemingly unrelated sections of the site break for unknown reasons.

Related Topic