1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Best way to learn OO PHP

Discussion in 'PHP' started by Marko Platanic, May 19, 2014.

  1. #1
    Best way to learn Object Oriented PHP (MVC)?
    Start learning with framework, or not? Which tutorial have best explanation?

    Thanks in advance for your help and time.
     
    Solved! View solution.
    Marko Platanic, May 19, 2014 IP
  2. easyturnkeywebsites

    easyturnkeywebsites Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    In my own experience, its best not to start out using any MVC framework. Most of them are really bloated anyway. In fact, the best way to learn PHP is to find a problem that PHP is going to solve. For your example, why not design your own MVC framework. This way, you can learn how MVC frameworks work, learn to develop in OOP and get better at PHP.
    i often find it easier to learn OOP with pen and pad to start so you can see where all the relationships are. there are also plenty of tutorials available on the net. type "learn OOP PHP tutorial" and you will get hundreds.
     
    easyturnkeywebsites, May 20, 2014 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,494
    Likes Received:
    4,457
    Best Answers:
    123
    Trophy Points:
    665
    #3
    I'd go through the tutorials that @easyturnkeywebsites has mentioned but I wouldn't go creating your own mvc framework.

    The big question is why you want to learn to use OOP - is it so you can implement your own changes to existing sites? or because you have a big project in mind that will need a fresh approach? or is it just for the intellectual challenge of understanding the concepts?

    Working with existing mvc frameworks is a good way to apply knowledge and while all will have bloat it can be useful to wade through their code (a little bit at a time) to see why it's there. Sometimes its legacy code that needs to be re-engineered, other times it will be to provide flexibility (that you may not need but others will). Nothing is ever pure, there are always compromises in a big project.
     
    sarahk, May 20, 2014 IP
  4. easyturnkeywebsites

    easyturnkeywebsites Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    @sarahk i would have to disagree on that. talk to any programmer and trying to understand other peoples code is sometimes impossible. The only way to learn is by practice. Trying to learn looking at other peoples code is almost always a waste of time. The only time I would do that is if I want to optimise code already written to see if there was a better way of doing it.
     
    easyturnkeywebsites, May 20, 2014 IP
  5. sarahk

    sarahk iTamer Staff

    Messages:
    28,494
    Likes Received:
    4,457
    Best Answers:
    123
    Trophy Points:
    665
    #5
    I agree with that in principle too but lets say you understand the basics of inheritance etc
    Now, if you set up a test of joomla, wordpress and something else, say drupal and created an identical plugin for each - even just something that says "hello world". In doing that you'll get an understanding of how those sites have implemented classes, how they manage security and getting things to work together. All 3 will approach the tasks of navigation, admin and running the plugin differently and in working through them you'll have a better understanding of the underlying principles and the challenges of building a decent sized "system".

    If I look at code I wrote 15 years ago it's way less sophisticated than what I'd write today and each step of the way I've been influenced by the code I've worked with, I've learned more by having to debug and wade through source code to find where I've gone wrong - and yes, I've also fed code back where I've felt that improvements could be made.
     
    sarahk, May 20, 2014 IP
    ryan_uk likes this.
  6. #6
    Hi, I'm a professional PHP freelancer.

    Firstly, it's important to realise that whichever way you want to learn OO (Object Oriented) PHP, it's going to be a learning curve, and you're going to need to put in a sufficient number of hours to get to a decent level of competence.

    Going back to your question: Best way to learn Object Oriented PHP (MVC)? It sounds like you already have some PHP skills, and you would like to move into OO PHP development. Depending on your current level of competency with PHP development, I'd recommend two possible avenues for you:

    Scenario 1: You've done very little PHP programming, either OO on non-OO
    If this is the case, then before even thinking about OO, you should spend a good amount of time getting familiar with basic, procedural PHP programming. For this, basic, early understanding, I would recommend a very well known Sitepoint book by Kevin Yank, entitled "Build your own Database Driven Website using PHP & MySQL". This will help to get you started with the basics of PHP syntax, and also introduce SQL database queries to you. It's a great book for people who are new to PHP. Once you've worked through that book, you will be familiar with Procedural PHP programming, and quite a few inbuilt PHP functions to help you code efficiently. Don't stop there though...

    Scenario 2: You're already familiar with Procedural PHP and some SQL syntax
    The next step is definitely OOP (Object Oriented Programming), and in my opinion, the best place to start is with an MVC framework. People have lot's of different views on which framework to go for. Personally, I would recommend going for Codeigniter in the first instance. It's really relatively straightforward to use and very well documented. The framework can be downloaded from http://ellislab.com/codeigniter. The documentation is also available there. Work through the online tutuorials and read through the User Guide. Then get to work on a project. Once you're familiar with working in Codeigniter (or another framework) you can start gathering more knowledge about OOP. "PHP Master", also from Sitepoint is one good book on the subject.

    If you really want to progress then you need to be working on a project you enjoy. Whether it's for yourself, a friend, a colleague, or a business, find a project and then use this as a basis for practice in developing your skills. Sure, you won't get it perfect first time, in fact far from it, but the only way to get really good is to put the practice in. And there's no doubt about it, it really is a fantastic skill to have once you've nailed it.

    Hope this helps
     
    mikejwatson, May 21, 2014 IP
  7. Jigney

    Jigney Active Member

    Messages:
    168
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    93
    #7
    You want to learn OOP concepts in php, So i hope you know all the basic and CORE PHP.

    If you know C++ concept, than it's very easy for you to understand and learn OOP but don't worry if you don't know..

    First of all just try to read OOP therory basic not in any language just OOP Concepts.
    Don't waste much time in that just understand the main concept of CLASS, OBJECT, FUNCTION, METHOD and all that,

    Than find any readymade project which had used OOP concept and try to understand it,And make changes in it and fill the difference between outputs.
    Because just by reading a theory, you will not understand the implementation,
    You can find here some good examples : http://www.codecademy.com/tracks/php

     
    Jigney, May 21, 2014 IP
    Marko Platanic likes this.
  8. Marko Platanic

    Marko Platanic Active Member

    Messages:
    30
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    53
    #8
    @mikejwatson thanks you. My scenario is number 2 :) I will start with CI. Thanks to everyone for being kind and answer on my quiestio
     
    Marko Platanic, May 25, 2014 IP