Title is the question. And why I am asking is because from what I read about most PHP frameworks (e.g. Code Igniter, Kohana, Cake, Zend) is that they're ether too complex, or are designed mostly for small applications (like blogs).
If you were to build an app like Craigslist, would use an off-the-shelf framework or write your own?
-
8Don't believe everything you read. – Byron Whitlock Jan 07 '11 at 22:11
-
12@Byron - isn't your comment a bit self defeating? – Jan 07 '11 at 22:13
-
2@SODA - The main problem I have with the various PHP frameworks is they are often designed with specific use-cases in mind. That doesn't mean you can't use one, you just have to research carefully to make sure that whatever you choose supports all your features you want to use, or at least has a clear way to add your own custom plugin. I think of the off the shelf stuff Symfony is great. A little complex but it has excellent documentation. I've also rolled my own. I think it depends entirely on the situation. – Jan 07 '11 at 22:17
-
3Does anyone else think that this question sounds like, "Complex frameworks are too big for small applications, and small frameworks are too simple for complex applications"? – erjiang Jan 07 '11 at 22:18
-
Zend is not pre-minded, it's a collection of tools. If it's too complex for you don't try to do a craiglist-like website :-) as you will need to handle some complex things. – Jan 07 '11 at 22:31
-
If I were to build an app like Craigslist I'd read up on something called the "network effect" before worrying about frameworks. – Mark Ransom Jan 07 '11 at 23:00
-
@Mark Ransom - what about the "Network effect" are you referring to? – Jan 07 '11 at 23:05
-
@SODA, I was being a bit tongue in cheek, hoping you already knew what it meant. Basically I'm advising against building a Craigslist competitor unless you have some captive audience of users to cater to. http://en.wikipedia.org/wiki/Network_effect – Mark Ransom Jan 07 '11 at 23:12
-
Heehee. Seems like you raised a bit of a hot button for some developers on this one! – Jan 07 '11 at 23:33
-
2@cfreak, only if Byron had said "anything". – Jan 08 '11 at 18:30
8 Answers
I'd always use an off-the-shelf framework. There is almost never a good reason to build your own from the ground up. You'll spend a lot more time with the plumbing work and bug fixing writing your own than relying on tested and optimized methods already existing in the OS packages. Most of the frameworks have built in methods to extend them if needed and if they don't, I hear PHP frameworks are pretty easy to go in and modify as needed ;)
My suggestion is to evaluate a few of them and pick which one suits your needs. I've tried Yii, Kohana and CodeIgniter and found CodeIgniter to have the smallest learning curve and yet still supplies (almost) all of the functionality I needed for my application. For functionality not included out of the box in CI, they expose hooks for customization.

- 17,555
- 1
- 47
- 81
-
3@Demian: I strongly disagree. *Off-the-shelf* frameworks aim at being generic, often including a lot more than you actually need for a specific application. This can become tedious when debugging and optimizing. Why use 10 classes when all you need is one? – Jan 07 '11 at 22:43
-
8@netcoder: Sure, off-the-shelf frameworks aim at being generic. Coming from a C/C++ background, would I re-write the STL because it's generic and I think my implementation would be more optimal? No. Why? Because the library has been written, tested and optimized by people with far more experience in developing libraries than I have. Same holds true here. The benefit of the off-the-shelf frameworks is that both they're tested and optimized for you already and that they can boost productivity a TON once you've wrapped your head around them. – Jan 07 '11 at 22:51
-
@Demian: There's a difference between a library (e.g.: C++ Stdlib) and a framework (e.g.: Platinum). The biggest being that a framework, like its name says, rarely allows you to work outside the boundaries of the *frame*. A library is usually a small unit of reusable code. Libraries and frameworks are NOT the same thing. – Jan 07 '11 at 22:56
-
2@netcoder: Granted, the example may not have been the best (framework vs. library), but the gist of it remains true. Frameworks are tested and optimized and are proven to boost productivity. And at the end of the day, whether it's commercial or personal, who doesn't want to be more productive at the expense of a few interpreter cycles? – Jan 07 '11 at 23:01
-
2@Demian: Sure frameworks are optimized, but for what? They're optimized for genericness. *Optimized for you* and *aim at being generic* just don't go together: one is specific, one is generic. – Jan 07 '11 at 23:03
-
@netcoder: this is a great point of Zned framework, it's a framework if you want to use all the core components (MVC, etc) AND it's as well a library with a lot of very useful components, with good OO design pattern which make them quite independant of the core components. As n example you can use Zend_Db_* components for database access in any PHP project. – Jan 07 '11 at 23:04
-
1Frameworks, such as CI, only load the classes, etc that you WANT to run. Really, you could build your own framework on TOP of CI just to get your personal optimizations, but to what benefit? I'd love to see ANY employer or client for that matter who would take personal optimization over an increase in productivity. – Jan 07 '11 at 23:05
-
@regilero: Zend is probably the worst. They say it's loosely coupled. Want to use Zend_Gdata? You need Zend_Http, Zend_Loader and probably Zend_Youtube, which themselves need Zend_Uri, which itself may require Zend_Filter and Zend_Validate. Same goes for Zend_Pdf... it probably won't work without Zend_Loader and Zend_Memory, and these also have their own dependencies. And statically accessed members everywhere... By the time you figure all that out, you have 15MB in classes to load, most can't be overridden because accessed statically, and I've done the same Gdata call with 15 lines of cURL. – Jan 07 '11 at 23:15
-
so whats your problem? if the API changes, the wrapper of frameworks quickly changes FOR YOU (the community of good frameworks anyway). if you write all thousand API calls yourself, good luck doing that on your own. there is a reason why you use frameworks and libs for those things. who cares about a few more classes on a high end server? the difference in speed is nothing compared to the developer's time if he goes down your path. AND code is never foolproof and without coding errors. again, the framework libs fix themselves, whereas otherwise you end up doing it all alone! – Jan 07 '11 at 23:22
-
@netcoder, depends of the tools you need, of course high levels tools have dependencies... but be careful, my troll-o-meter comes in red zone. "worst" is maybe not the "right" term. – Jan 07 '11 at 23:25
-
2I've spent more time debugging and overriding Zend than it saved me from using it in the first place. As for the troll-o-meter, well not at all, this is an argumentative question and it doesn't belong on SO anyway, which is probably why it has a couple close votes already. – Jan 07 '11 at 23:32
-
well, i wouldnt use Zend either, there are other frameworks with less widespread dependencies :) – Jan 08 '11 at 00:00
I've written virtually all of my sites from scratch. In my case, the reason is primarily because I enjoy creating things and that's also a great way to learn. It's much less fun for me to spend time trying to learn someone else's code than creating my own.
But that's just a personal reason. If you find a nice off-the-shelf package that does exactly what you need, then I could certainly understand using it.

- 589
- 1
- 3
- 10
-
3Wait till you see the productivity enhancements you get when you learn a good framework. You also are ignoring that learning to do it your way isn't always the best way. There are some sound well thought out patterns and ideas in the major frameworks. But it is definitely more fun to reinvent the wheel. :) – Byron Whitlock Jan 07 '11 at 22:26
-
Building site frameworks from scratch is not synonymous with not learning. In fact, I would strongly suggest the opposite is true. While developing a site, I do a lot of research and ask a lot of questions to learn how other people might have done it. How is learning someone else's interface and ignoring how their code works a better learning experience? – Jan 07 '11 at 22:44
-
Most of the time, I don't care to write another login module. I know how to do it, i've done it a million times, I don't want to do it again. Also Zend, codeignighter etc have had many contributors. The codebase is the sum knowledge of many coders. And if you haven't taken a serious look at how others have done it, you will certainly miss out. Not all frameworks are equal, Cake is all auto-magical garbage that I personally hate. Zend is more like a OOP extension of the php standard functions. – Byron Whitlock Jan 07 '11 at 22:51
-
In todays time its usually inadequate to build everything yourself. you dont have the time and/or the manpower. especially since everything changes so quickly. after a few months/years, the database access, the underlaying php, xml, json, ... might have totally changed. you cannot adapt everything on your own all the time. a framework does that for you. you can stay focused on your main task: DEVELOPING. – Jan 07 '11 at 23:15
-
Right, you can't develop everything yourself. So instead of using assembly language anymore, I use tools like C#, .NET, ASP.NET, etc. But that doesn't mean I can't still write software. And learning about algorithms and, for example, the most efficient way to store and retrieve tags in a database is what I enjoy. If someone prefers using higher level components, I can respect that. But if someone is adamant that only Microsoft and a few select developers should work on algorithm-type stuff, then I think you're way out of whack. – Jan 07 '11 at 23:30
-
@mark: Whether you are using a framework or not, doesn't change the fact that you are "developing". I tend to disagree with the fact that frameworks increase productivity, because productivity doesn't mean having a website or application up-and-running as fast as possible. It means "the ability to produce" (and by produce here we mean quality before time, because who wants crappy software). Just because you don't use a framework doesn't mean you aren't productive. – Jan 08 '11 at 07:49
-
@Jonathan, if you build everything from scratch you also have to maintain the thing you've written yourself. This makes you alone the bottleneck of your system, and - unfortunately - individuals don't scale. In other words, at one point you will not have time to do all the work that is necessary for you to keep your current pace. By leveraging the works of others (which you've chosen wisely) you essentially buy yourself more time. If you say, nah - no problem, then you just haven't gotten traffic enough yet. – Jan 08 '11 at 18:34
If your primary motivation is to get something done (as opposed to learning), my general advice is that I would first go with whatever you already know and are comfortable with that can handle the job well. If a task exceeds your capabilities at the moment you then look for a package that extend your capabilities to handle it.
-
Well there is a saying that "It's not best to swap horses while crossing the river" - meaning that if you have a working app that needs to be scaled, it's probably too late to start re-coding it using another approach, another framework etc. – Jan 07 '11 at 22:37
-
1Look at most successful websites: Facebook, Twitter, etc. What percent of those used an off-the-shelf solution? – Jan 07 '11 at 23:38
-
My argument was not in support of off-the-shelf frameworks, but to say that swapping platform in the middle is a bad idea. – Jan 07 '11 at 23:45
-
@Jonathan Wood - what both Facebook and Twitter did was start with something technically simple (though innovative) and build from that. They didn't sit in a corner and program and conjure up success. And I am pretty damn sure that both facebook and twitter have looked into other existing solutions and used many that they have found would increase their pace and stability. – pellepim Jan 07 '11 at 23:53
-
@pellepim: So you agree that these most successful sites wrote them from scratch. Good. – Jan 08 '11 at 00:00
-
@SODA: Well, that's fine but that's not the question you asked that started the discussion. – Jan 08 '11 at 00:01
-
@Jonathan, and how many programmers did they have doing it, and WHEN? They didn't do it from scratch... – Jan 08 '11 at 18:35
-
Specifically Twitter started with a vastly unfitting framework (RoR) and changed its architecture drastically as it grew; now it's being more and more reimplemented in Scala. Releasing fast may be more important than having it future-proof from day one. – 9000 Mar 26 '11 at 09:33
I am about 90% done with a craigslist-type application. I have built it from scratch using straight PHP, and things have came along quite well. We are now finalizing things and adding some advanced features that you do not see in any classified websites.
Programming frameworks are useful when you're working closely with a group of developers, have tight deadlines, need to implement web api's like twitter and facebook, and are developing large systems with 10+ DB tables.
If you're coding alone, on small personal projects, or sites which aren't time critical, and basically exist in a vacuum, then doing it by hand without a framework is fine, and IS faster.
I've made fully custom CMS within two weeks without a framework. On the flip side, when I code with other developers, having systems such as CVS / SVN / Git, and following the conventions of a framework are invaluable. My solo coding eccentricities don't confuse the other developers, just as their solo coding eccentricities don't confuse me, when we're all using a framework. Plus, I don't have to rewrite an entire Twitter OAuth class and Twitter API class, which would take a week or more by hand.
I would use Codeigniter. It's the least like a framework in comparison to Zend, Kohana, Yii, Cake, Symfony and any other known PHP framework. It has a small footprint, it is dead easy to learn and really powerful. The only downside is no out-of-the-box ACL, but there are many great pre-written libraries out there to add that in.
I've been using it for quite a while now and have written both small and very large applications on it. And when I say large I mean almost enterprise type of large. Due to NDA's I cannot say exactly what, but trust me, Codeigniter has no limit in terms of what can be done with it.

- 192
- 4
I would always choose to write it myself.
Learning alone is enough of a reason (and why I would disagree Demian Brecht's answer). In our career field, knowledge is king. The more you have, the more valuable you are as a problem solver.
But the other thing is: I just always have the belief that I can do it better. Maybe that's ego talking, but I just believe it.

- 2,244
- 14
- 14
It really depends on the context of the application.
If this was simply a classified ad system for a local community group or church, I'd use a canned system.
If this was the core application for a business, I'd write it from the ground up. This way the code base is 100% known and understood, and it'd be designed specifically for the task at hand. It wouldnt be completely 'from scratch', I guess, as I'd re-use/adopt a lot of classes from other projects, and I'm sure there'd be 3rd party pieces used for various features (mailing, image generation, etc). But the basic frame of the application would be designed specifically for the application by the company, and not rely on a third party framework.

- 37,990
- 7
- 78
- 131