Are frameworks really necessary in PHP?

What are the advantages and disadvantages of using one?


6 Answers 6


No. But they are nice.

Pros: Saves time not having to rebuild the code yourself. Use the myriad of features, functions, and data structures someone else built that apply to your project.

Cons: Not having built the code yourself could be a loss at a better level of understanding on the foundation of which your project operates.

  • 1
    but the problem is that day by day there are alots of frameworks i dont know which one to use Apr 6, 2011 at 11:58
  • 4
    @Tayyab You gotta use `em all! Apr 6, 2011 at 12:12
  • 1
    Choosing a framework is for you to decide, based on the needs of your application and your coding style. Also ask yourself, do you need a framework to roll your own app, or a CMS (Joomla, Drupal, etc)? Apr 6, 2011 at 12:15
  • 3
    You have to be careful about "unknown unknowns". If you don't use a framework, the risk of forgetting or not knowing about some stuff that frameworks solve for you is large. For example, are you correctly dealing with CSRF attack prevention? Your app will work without such a prevention, but it will be easily hacked. Choosing a major framework (any of them) means you benefit from all the stuff that web apps have to concern themselves with, even if you haven't learned about it yet. Mar 13, 2013 at 11:02

Web application frameworks are only as good as your experience with them.

Every framework has a learning curve, until you overcome that curve, you'll probably end up doing things so ass backwards that you negate all of the benefits of using a framework. Your application will be needlessly slow to develop, the code will be difficult to follow and the whole thing will break when a new version of the framework is released. I would recommend against attempting to use an unfamiliar framework (or any unfamiliar technology) for projects with a tight deadline.

How does one get better at utilizing frameworks?

You'll have to build a handful of god awful applications and iterate. Eventually you'll figure out the quirks, and using a framework will allow you shorter development time and better organized code.

Should you use a PHP framework?

Everyone who codes enough PHP eventually uses a framework. The question is, will you use your own framework or one developed by a third party? In my experience, you'll likely never develop your own framework which will match the robustness and quality of a third party framework. That said, developing your own framework seems to be a right of passage in the PHP community, so, don't let me discourage you from writing your own database abstraction class.

Here is a helpful graph:

enter image description here


According to Rasmus Lerdorf, you don't need any additional framework, as PHP is itself a framework. http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html

  • well guys i am a biginner and i am trying to write code i am new to it and i want to be a core developer of php so please guys suggest me Apr 6, 2011 at 13:12
  • 3
    That article is from 2006, and is embarrassingly out of date. Mar 13, 2013 at 13:53
  • 1
    @JonathanRich: that article might even be out of date, but it's still embarrassingly interesting!
    – user53226
    Dec 20, 2014 at 19:50

Well, it really depends on the size of your project. A homepage with no database and no more than 10 pages, a framework is going to be too much, mainly because framewroks always need a lot of configuration and customization in most cases, to fit specific needs. And in some situations they could be a little slower than several pages included in a file (think about all the framework needs to load to use its features.).

Now, if you are planning a mid/big size site, with database interactions, webservices, etc etc, you will need a framework to help you interact with different technologies and organize your code in a way that when things break, you'll have the habilitie to quickly detect and repair it. Also if you think about clients, they are always changing their mind about software, so if the client needs to modify or add a new feature you should not have to go trough all your code and think about how do i plug this new feature in all this sphagetti.

There are lots of others pros and cons, but these are the ones first crossed my mind.

Edit: I use symfony framework in daily bases and also done work with php for the university (i had some courses about web development that doesn't allowed to use any framework), so most of this comes from that experience.

  • 1
    well i am a beginner in php and have not develop any thing big yet and i am to confused what to use and which i should go for really i am totally blank Apr 6, 2011 at 12:14
  • First step would be not use them, learn the technologies and how they work (php , framework, js, css, etc), then once you have understood the basis of php programming, then use a framework like Zend or Symfony or CakePHP to learn how to boost your applications
    – guiman
    Apr 6, 2011 at 12:16

You're kidding right?

Necessity depends on use. Computers aren't necessary to mankind, neither cars, etc.

As to advantages/disadvantages, to each it's own!

I'd like to show some example code off my own framework:

class Product extends DatabaseRow {
    public $name='';
    public $price=0.0;
    public $images=array();
    public $description='';
    public table(){
        return 'products';

$p=new Product();
$p->description='Our premium diet bread.';

See what I did there? That class serves as a model for a shop. What's so special other than OO? If the table, or any column doesn't exist, it is created dynamically. 0 install scripts. Of course, this is a specific feature in my framework. But you get the idea.

  • i want to tell u some thing guys actually i am using 2 frameworks one is codeigniter and the other is yii and i want to become a core developer but my OOP Concepts are not so good the truth is that . Apr 6, 2011 at 13:19
  • How do you differentiate between an 'UPDATE' and 'INSERT' statement in the $p->save() method ?
    – Srisa
    Apr 6, 2011 at 13:42
  • @Srisa - I didn't set an ID. To do an UPDATE, I need: $p=new Product($the_id); $p->load(); The load() is to the a row merge as opposed to overwriting the whole row.
    – Christian
    Apr 6, 2011 at 14:32

Not all applications require a framework, but most consequential ones do.

The advantages are:

  • Don't repeat yourself - Any new application is will have functionality in common with many existing applications. It makes sense to avoid repeating yourself. A framework bundles functionality you'll need for most applications. You'll consequently save time (and money).
  • Don't drudge yourself - Software development in general can be quite grindingly painful. It makes sense to automate the mundane stuff. A framework takes care of the plumbing, so you can focus on being profoundly creative. You'll consequently save effort (and money).

The disadvantages are:

  • Our way or no way - You may have to follow the framework's rigid conventions, which might contravene your dogmatic beliefs about how things should be done (and consequently enrage you).
  • Acquired framework syndrome - You may become too dependent on frameworks to get even the simplest things done. You'll forget how to route requests, access databases, map objects to database queries, etc since the framework holds your hand through all that.

All in all, it's better to use one.

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