4

I'm kind of new to PHP. I can create basic sites with login/registration, etc., but I always struggle to build complex sites with lots of features, because eventually the code becomes messy and I just run into more and more little bugs, and then fixing those produces another, and so on. I realise that that's partially to do with me simply not writing clean code (I'm working on that!) but I would also probably benefit from using a framework.

But is using ready-made frameworks "unprofessional"? Would a big site such a YouTube or Facebook use a framework like CakePHP or CodeIgniter?

  • 3
    There are two kinds of "big". Having many features and having many users. For sites with many users, performance often trumps development effort. – CodesInChaos Nov 24 '13 at 20:39
  • 1
    There are many big sites written with frameworks. They are so widespread nowadays that your assumption they could be "unprofessional" just majes no nsense at all. – thorsten müller Nov 24 '13 at 20:48
  • 5
    What's “unprofessional” is doing work yourself when someone else has done a better job and allowed you to (re)use it… – Donal Fellows Nov 24 '13 at 21:14
  • 5
    We use the MVC framework on Stack Overflow (and of course the rest of the Stack Exchange network) - does that count? – Oded Nov 24 '13 at 21:52
  • 3
    @CodeCrack CodeIgniter is pure horse crap. If you compare all of the crappy PHP frameworks to a garbage bag, CodeIgniter is the liquid that's dripping from the bottom. – Madara Uchiha Oct 25 '14 at 22:32
12

Using a framework is like choosing a library: you get some features for "free", but you also get the limitations of this code (for example, using a data-access library might prevent you to write a five-way join query).

The problem with choosing a framework is that it is harder to revert your choice once you have started using it. The reason is that frameworks usually have lots of responsibilities, and often use shortcuts (e.g. "convention over configuration") to make things easier to write. So your code ends up tightly coupled with the framework, and moving to another framework implies a total rewrite.

So it is not unprofessional to use a framework. I heard some good success stories with symfony. But it is an important choice to make. And it should be a well informed decision (you should build a small/medium project with a given framework before considering to use it for a big business).

6

When projects scale to a certain size, a framework is inevitable. You can explicitly choose a framework, or you can implicitly accrete it. If you do not explicitly choose to design / adopt a framework or architecture, you will still have one, it will just be a very badly designed one, and it will be much harder to add new functionality without introducing bugs (as you have already experienced). If you do not yet have the skill to design your own framework, it is better to choose a well-known framework, as it will save you time in the long run.

Specifically about your examples:

Youtube uses python for its front-end, but it spends most of its time in back-end services. In large sites you typically find this architecture where everything that takes up considerable time is moved out of the front-end servers and into a back-end service layer which can be scaled independently from the front-end. From what I can find they seem to have rolled their own framework. For more info, see http://highscalability.com/youtube-architecture

Facebook uses PHP for its front-end, and they also spend a lot of time dispatching to back-end services. Again their framework is home-grown, but they have even gone so far as to build their own PHP engine and development tools. They've open-sourced some of their framework code as well.

  • Facebook and Google are good examples of companies creating their own frameworks. The question if it makes sense for you is mostly a function of what you need, and whether that can be achieved with existing Tools (highly recommendable) or whether you absolutely need to improve things beyond the existing, because no combination of the available tools does fit your needs. But that's a hard way to go, because of necessary upfront investments, maintenance and further development, so I would really recommend to follow Joeri's recommendation and start with existing frameworks. – JensG Nov 26 '13 at 19:17
  • Wait what, they use Python for front-end? I fail to see why would they opt for that, the only thing it can do (AFAIK) is spit out HTML via a templating engine of some sort. WebAssembly is not yet really used, let alone 5 years ago when the answer was written.. – Milan Velebit Aug 28 '18 at 7:46
  • I think I meant "the front-end application", meaning the part that generates the HTML on the server, as compared to "the back-end services", the things that are running one layer deeper in the network architecture. – Joeri Sebrechts Sep 3 '18 at 10:55
4

There are different kind of Framework:

  1. Data frameworks (ORM) which provide basic functionalities to manage data : eg. Doctrime2
  2. Kernel frameworks which provide basic functionalities to manage components : eg. cuteflow
  3. Application frameworks provide user functionalities: eg. eZ Comps

using framework is a big choice, because they solve common problems and help the developer to make more readable and self-documented code, but they require a lot of time and experience to be dominated.

For java developer it's a little bit different because Oracle defines standard (JSR) and different framework's producer adapt their framework and it's (relatively) easy to jump from a frameowrk to another.

In PHP framework is like a diamond ... it is forever (+ or -)

0

I don't think that using a framework is a problem. In fact, it brings a lot of useful features and benefits, such as unit testing, good practices, or stability of your code. Zend and Symphony are good examples of frameworks that enhance your coding abilities.

However, using a framework does not make your code more performant. There are many other factors which need to be considered in order to make your application run fast.

Answering your question: yes, frameworks are used in big websites.

  • 1
    I find your post almost impossible to parse; is there anyone nearby that could help you with your English? I'd edit this but have no idea what you are trying to say. – Martijn Pieters Feb 8 '14 at 1:01
0

Even if you don't use a framework you end up with your own anyway.

You're going to have standards in your company, libraries which you use, conventions. And at some point your own small or big project will basically have its' own custom framework. (although you probably won't call it that.)

protected by gnat Oct 2 '14 at 19:46

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?