Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have been coding PHP for about 2 years now and I THINK that I have a very good grasps of the fundamental parts of PHP, i.e.

  • Functions
  • foreach/IF statements
  • sessions/cookies
  • POST/GET

Amongst a few others.

I want to move on to learning OOP PHP now, so learning how to use classes and making it a really valuable skill.

I have 1 requirement, the source must be a respected source that doesn't teach developers bad habits.

I have the book: PHP and MySQL Web Development

However, as useful as that is I would like an online source.

I would like to know from people with experience in OOP PHP, how and where did they learn OOP PHP. Obviously by doing, but I would really appreciate some great resources which help me along the way.

share|improve this question

closed as off-topic by gnat, Bart van Ingen Schenau, MichaelT, GlenH7, Simon Jan 2 at 10:40

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions seeking career or education advice are off topic on Programmers. They are only meaningful to the asker and do not generate lasting value for the broader programming community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – gnat, Simon
  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Bart van Ingen Schenau, MichaelT, GlenH7
If this question can be reworded to fit the rules in the help center, please edit the question.

3  
Answers to this I think depend on your background. Learning OOP is not PHP specific, it is a general idea that lots of languages use in some capacity. –  Chris Aug 17 '11 at 20:20
    
I don't see getting an OOP book that uses Java examples to be as beneficial in this case. –  JeffO Aug 18 '11 at 1:11

5 Answers 5

up vote 2 down vote accepted
  1. Learn the technical stuff. Learn syntax for creating classes, for extending them, for implementing interfaces. Learn what private/protected/public means. Don't bother with writing any serious OO code yet. Just get comfortable with piping.

  2. Check out some simple design patters like Observer (a.k.a Listener), Decorator, Composite or Iterator. This was for me, where I finally understood what OOP is about, and how to use in practical way all the stuff I've learned in pt. 1

share|improve this answer

Write some test code with test objects, and see how things work and how you can use things like static methods, inheritance, magic methods, etc. Also, some parts of the PHP manual are useful to browse, like here: http://www.php.net/manual/en/ref.classobj.php

share|improve this answer

I'd say pick up a framework, such as Cake, CodeIgniter, or Zend, and learn from their documentation and use them to narrow down the list of options for books. Regardless of what you think about frameworks, the big ones are written by people who are generally considered respected, and the framework itself will provide you with a code base to study and a means of developing stuff fast (so you're not spending half your time dealing with basic CRUD stuff when you're trying to learn the OOP way of manipulating that data). Bonus points if you can find a book written by one of the core developers for your chosen framework.

Also, don't just limit yourself to PHP-based stuff. Find resources on standard principles of OOP. They'll provide you with the foundation that will allow you to carry your knowledge into other languages. By going this route, you don't have to worry as much about how recently the text came out, as the underlying principles haven't changed that much, which opens you up to things like older college textbooks that you can grab from used book stores, eBay, or ebook sources, such as Scribd.

share|improve this answer
2  
Frameworks are overrated, and they won't teach you how to do OO well. They'll only give you a vague understanding. –  B T Aug 17 '11 at 20:32
    
Also, the Symfony framework has great, free books written but its core developers: symfony-project.org/doc/1_4 –  CamelBlues Aug 17 '11 at 20:59
    
@BT - Hence why I said to look at the documentation and find books that utilize them. Doing it that way provides you with functional examples, the ability to quickly build your own stuff, and, as I already mentioned, will narrow down the number of books to sift through. In other words, it's a starting point. –  Shauna Aug 18 '11 at 20:00

Why would like to learn OOP for? Is it for yourself, or do you want to use 3rd party tools (for example the frameworks mentioned before)?

If you would like to understand OOP well, I would recommend to "throw away" PHP for a little while for this process. You should definitely try to check the different languages with "OOP support" and play a bit around, for example try to implement a design pattern with each of those.

I think we have quite a discussion about using OOP with PHP and everyone around has an opinion. Mine is: we should definitely learn when to use OOP, as some times it feels like an overkill [for example in opensource projects it can raise the entry level for programmers if it isn't done right]. OOP is for making better applications, not for confusing programmers.

share|improve this answer

There are certainly a wealth of resources on the internet explaining php classes in detail. Finding the ones that transfers the message easily and clearly is another thing. A book is usually the best way because of it's structure and teaching one from the begin to the end in a logical and chronological manner. To dive into classes and OOP design I would suggest nettuts+ http://net.tutsplus.com/tutorials/php/oop-in-php/ and http://net.tutsplus.com/tutorials/php/object-oriented-php-for-beginners/ that explains it step-by-step and is simple to understand.

share|improve this answer

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