vote up 0 vote down
star

We are starting a new app and are debating the benefits of MVC (using CodeIgniter for PHP) vs. using object oriented PHP.

I myself only really started using object oriented PHP, and do like it, but should I use that over codeigniter? I see benefits of both.

offensive?
add comment

12 Answers:

vote up 4 vote down
check

As mentioned by others, MVC and OOP are not mutually exclusive. In fact, most good MVC frameworks are object oriented. I would highly recommend checking out the Zend Framework as well.

link|offensive?
add comment
vote up 11 vote down

They're not mutually exclusive - you can do MVC in an OO language.

link|offensive?
add comment
vote up 2 vote down

CodeIgniter is not what I would call a full-stack MVC implementation, but more a collection of useful libraries that can be used together to produce an MVC architecture.

If you're interested in 'complete' Model-View-Controller implementations in PHP, I would take a look at CakePHP or Symfony.

link|offensive?
add comment
vote up 1 vote down

You can use both at once, indeed I do at the moment.

I have found the MVC is very useful as it means that designers and developers don't step on each other's toes so often.

Object orientated programming for me makes the code neater and easier to understand.

link|offensive?
add comment
vote up 1 vote down

Kohana is a fantastic port of Codeig that has a great ORM layer. (kohahaphp.com)

link|offensive?
add comment
vote up 1 vote down

CodeIgniter is highly Object oriented so there really isn't much different! CodeIgniter is great as you get a lot of existing libraries for stuff you don't have to code again, e.g form validation, calendar,etc. You also get search-engine-friendly URLs in the format:

www.site.com/class/function/variable

which I find really productive.

Hope this helps!

link|offensive?
add comment
vote up 0 vote down

I would recommend an MVC framework, it really helps the enforcement of good design, and imo speeds up development.

pure PHP will work and is good for small to medium projects, but without a organized MVC framework, I find it easy to lapse and start slinging PHP code everywhere...

I have never used CodeIgniter (I used the Zend Framework) but I would certainly go the MVC route...

Thats my 2 cents.

link|offensive?
add comment
vote up 0 vote down

CodeIgniter is actually an object oriented framework. You can do MVC with it, but you're not required to. It's still a good base for building an application with, regardless of whether you use the MVC components or not.

link|offensive?
add comment
vote up 0 vote down

Using the Model-View-Controller pattern is a great idea. Before you dive into that consider the Presentation-Abstraction-Control pattern, which is further development on MVC for more complex interfaces. In any case, separating out the layers will have a number of benefits.

I'll go against the popular grain when it comes to OOP. If you aren't comfortable with OOP you don't need to use it. You can still write a MVC setup procedurally. If you are comfortable with OOP, by all means, go for it. Some great apps have and are still written procedurally. Still others are OO.

If you are going to use a framework check out CodeIgnitor, Symfony, or Zend. Others are good. These three are pretty fast and give you a variety of options. CodeIgnitor is really lightweight and barely a framework. Symfony is a good MVC framework. And, Zend is give you the ability to architect your own structure and provides the most freedom.

If you aren't much of a coder (and that's ok) or are looking for something that does a little more for you check out drupal and Joomla!. They are content management frameworks and do a good job separating the layers like the straight up frameworks do but may be easier to use for a non-coder or someone looking to code less.

Go with what's comfortable but try to use a separated layers (MVC or PAC).

link|offensive?
comments (1)
vote up 0 vote down

I'm not sure what you mean by "object-oriented PHP", but CodeIgniter is a very good framework to quickly create web applications. It certainly beats writing your own object-oriented framework first, and then using it to write your application...

And, as stated above, CodeIgniter is object-oriented.

link|offensive?
add comment
vote up 0 vote down

separatign view from data has been practiced since long before mvc word was introduced. even without mvc, you can create class libraries and create php pages which include required classes and call appropriate class methods. I don't prefer making separate files for views.

mvc is just a fancy name of separating of data access layer, processing page and layouts. I have seen many good non-mvc architectures. On web I believe its not necessary to have single page handling all page requests(common or front controller). You can create common include file and do common stuff right there.

link|offensive?
add comment
vote up 0 vote down

MVC or object oriented?

If you're not sure of the difference between MVC & object orientation, and "which would be better", this is what I would recommend:

  • First, look at a few "set it up and get going" tutorials for the CodeIgniter/Kohana, Zend, CakePHP, ezComponents, and Agavi frameworks.
  • Next, take note of what they have in common, and what some lack
  • Then, make Pros & Cons lists for each (including things as trivial as "I don't like the syntax XYZ Framework uses)
  • Lastly, try to build your own (simple) framework, incorporating some of what you like from the others, and none of what you dislike. This will help you come to a deeper understanding of MVC, object orientation, and what frameworks (in general) have to offer.

Now you're in a position to choose which one to use. Don't use the one you build; you'll just end up re-inventing many wheels, and wasting a lot of time. Stand on the shoulders of giants, and take advantage of what entire communities have built FOR YOU. That's why they exist.

link|offensive?
add comment

Your Answer:

Get an OpenID
or

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