views:

456

answers:

11
+3  Q: 

learning php OOP

Hi Guys,

I'm learning PHP and I'm not that familiar with OOP yet - I've read a book about it, but never really programmed using OOP.

I would also like to learn how to use a framework (codeIgniter, as it seems the most 'friendly' to beginners).

Now I need a suggestion from you: would you recommend learning FIRST the 'standalone' OOP and then move to codeigniter, or go directly to codeigniter as it will make me learn the basics of OOP anyway?

Thanks, Patrick

NOTE: I've seen a few replies like "learn first some 'real' oop using another language, then move back to PHP". I'm happy to take on board all suggestions, but I'd actually like to stay with PHP since the beginning, as I'm not planning to use other languages at the moment.

+4  A: 

i guess you should start with standalone OOP, and not go directly to frameworks. frameworks usually have well coded classes and functions, and you may not be able to understand exactly what it does.

Start from the beginning, learn how OOP works, then go to your framework.

My opinion.

Mihai Iorga
+1  A: 

It is always better to start from the basics so my advice is to start with 'standalone' OOP as you call it.

Anyway if you want to go further in the OOP you will have to learn some more powerful language to get the real ideas.

The php folks may not agree, but I think there is much more PHP must do to become a real OOP language

Svetlozar Angelov
A: 

Learning OOP "the PHP way" is something I would highly recommend you not to do.

PHP has so many quirks and obscurities that it will probably just cloud the issue and make it harder to understand. Learn OOP from a language that is designed with OOP in mind ground up, like Python or Ruby, then read up on how to apply your newly acquired OOP knowledge to PHP.

asbjornu
A: 

I had some basic knowledge of OOP, but learnt so much more when I jumped into a framework (a custom framework not dissimilar to CodeIgnighter).

So I would say take a look at some of the CodeIgnighter videos / demos / examples and have a play around. Also take special interest in Stack Overflow questions relating to OOP and help others where you can, remember, you learn 90% of what you teach.

ILMV
A: 

In my opinion I think Java might be a better start to learn OOP as PHP has a lot of procedural elements but the documentation is very good and I don't think you will have too much trouble.

Of course you would be better off learning the details of the language before getting involved in frameworks but if using a framework encourages you to stay with the language and later get a deeper understanding it might not be too bad.

As for codeigniter, tutsplus had a good series for beginners. Here is the link to part 7 which has references to the other parts:

CodeIgniter from Scratch Day 7

Also check out their page on beginning php.

RobbR
A: 

You can use codeigniter (CI) without knowledge of oop but you can't understand why it goes like that way.

It'll be hard to use it while you are new to oop. You'll do many mistakes and then learn the rigth way. But without oop knowledge you never understand why the right way is really right.

So: Learn oop and then maybe CI. As others said; php is not a perfect object oriented languale.

Ahmet Kakıcı
A: 

Learn OOP first. Then go frameworking.

This can be done in many ways, but it's actually not a bad idea to learn it from another language, but you must be prepared for the time when you run into hard walls writing object-oriented PHP because of the implementation.

A good starting point would be Java or C#, these are some of the major OOP languages and have a very large community online.

Without basic knowledge about PHP (this means actual experience by doing it, not reading about it) it's quite hard to grasp an object-oriented framework.

Also be sure to check out CakePHP. It's another PHP framework with interesting capabilities.

Peter Lindqvist
A: 

I'd say pick up a framework and learn how to use it.

If you're starting from scratch it'll help instill best practices, and the whole point of a framework is to provide a clear and flexible, um, framework; I can't think of a better teaching aid. I doubt you'll feel comfortable looking "under the hood" at first, so start by using the framework as it was intended and build a website or three. As you get more comfortable with PHP + OOP you'll venture further and further into the framework itself...

If you're starting from scratch and CodeIgnitor interests you, I'd suggest trying Kohana instead. It's written in strict OOP and most importantly a PHP 5 offshoot of Codeignitor. The PHP 5 bit is important because pre version 5, PHP didn't have a lot of fairly vital OOP features. CI is built to work with PHP 4 too, and as such contains some "munges" that pull it away from being a truly great starting point for OOP.

In response to the "PHP is teh OOP devil" comments; Yes, it is easier to "break" an OOP approach with PHP, but needing self-discipline is a terrible reason not to use it.

MatW
A: 

Basics first, then frameworks

Mithun P
A: 

go for java or c# for strong oops knowledge

pradeepa
A: 

What I recommend to do.

  1. Read some basic so that you understand what CI is doing. Just one or two days of reading basics.

  2. Dive into CI and learn CI.

  3. If you are stuck then read more php OOP.

shin