Oop php

Hi All,

Hope all is well.

Bit of an odd question this, but I’ve been tasked by my employer in getting my head around OOP PHP. Now can anyone on here recommend some great books that I can use to get dug in straight away. I have been working with PHP for around 5-6 years but never looked into the OOP side of things so could do with some great resources and tips please.

Thanks…

There haven’t been many threads on this subject recently, so here’s a few older ones:

http://www.sitepoint.com/forums/showthread.php?774730-Preparation-for-learning-PHP-easiest-programming-language-for-a-beginner-to-learn&highlight=oop+books
http://www.sitepoint.com/forums/showthread.php?807930-Advanced-PHP-books&highlight=oop+books

How you learn and the style of tutorial which communicates to you is a very personal thing. I always (boringly) say, go to the biggest bookshop you can find and browse the books and try and find those whose styles appeal to you.

Spend some time, and be prepared to come away with more than one book.

Do not look solely at PHP books, once you have the OOP syntax in your head then Java and C# demo code will be easy to understand.

You may think you are just going to learn OOP, but to do it properly you will have to learn about software design patterns and advanced programming theory - and this can take an awful long time.

Hi Cups,

Thanks for your reply.

Hmmmm I’ve got a couple of Java 5 and 6 books here, might be worth looking at those… (not a Java fan)… will also lay my hands on a few PHP/OOP books. I guess the only way to learn is through trial and error and I’m assuming the structure of OOP programming is near on the same for each OOP language??

I’m probably not the best qualified to answer that, but from what I have seen studying Java and Python (and JS I suppose) yes, they all share the same [google]OOP principles[/google].

OOP Design Patterns serve as a very good nomenclature across the languages.

Having said that, by the very nature of the environment in which it operates, some patterns are more frequently used in PHP and its worth tracking down the best and latest books aimed at it. I am not sure if there are new books any aimed specifically at PHP 5.3 or greater.

Going back to your original post, when your employers talks of OOP, perhaps they have in mind that they think you should be using an MVC framework? Deep-diving into OOP principles will of course set you up well to use an MVC framework to its best, but is certainly not a pre-requisite - which of course learning PHPs OOP syntax is.

I suspect that choice will depend on the nature of the work you do, and whether your day to day domain specific tasks and complexities will benefit from OOP practices, thinking and disciplines.

IMO all OOP study is good, and will make you a better programmer and also lead to the discovery of other “robust industry practices”.

Here’s a really good old post on learning OOP, which also amusingly cocks a snoot at my reply too. :wink:

Hi,

I would look at martinfowler.com and would pick up Patterns of Enterprise Application Architecture, [URL=“http://martinfowler.com/books.html#refactoring”]Refactoring: Improving the Design of Existing Code, and [URL=“http://www.phparch.com/books/phparchitects-guide-to-php-design-patterns/”]php|architect’s Guide to PHP Design Patterns (It is a little outdated but gives a gentle introduction to Unit Testing and Patterns). I might also check out these blogs:

You might want to look at PHP’s own documentation http://php.net/manual/en/language.oop5.php, http://php.net/manual/en/book.reflection.php, http://php.net/manual/en/class.iterator.php and http://php.net/manual/en/language.oop5.traits.php

Hope this helps,
Steve

Hi Cups,

Thanks again for your reply

My boss wants me to get my head around the concept of MVC. A lot of our work involves the frequent use of Joomla and Open Cart all big on this concept of MVC and I therefore take it on OOP. Will definately have a look at the various resources shared in this post and also pick up some of the books relating to OOP and MVC - although most of these are based around ASP.net :slight_smile:

Hi Steve,

Thank you for your reply.

Will certainly have a look at the resources and pick up a couple of the books you have recommended… thanks again :slight_smile:

I’d suggest getting your head around the concepts in OOP before moving onto MVC and design patterns. If you’re coming from a procedural background, then OOP can seem a little backwards insofar as you call functions (methods) on objects, rather than passing data into functions.

That’s the first step! After that, look at the basic patterns then move onto MVC and software architecture.

Firstly learn about the Principles of OOP. It isn’t all that complicated but you need to get your head around it before you start coding it.

The way I learnt is actually by looking at the code of an Open Source software that was coded in OO PHP.

Then I started creating some simple objects of my own to get the hang of it. Once you’ve got the concept and know how to make classes, its not as hard as it first seems and makes your coding so much more cleaner and you will never repeat code again :slight_smile:

Hi All,

Thank you for all your recommendations and resources.

I have since purchased a OOP PHP book, and will also be going back and forth to Amazon to pick up more

Thanks again