1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Getting up to speed in PHP and MVC.

Discussion in 'XenForo Development Discussions' started by Shaun Mason, Oct 28, 2010.

  1. Shaun Mason

    Shaun Mason Active Member

    Hi guys,

    During the daytime, I am a software developer for Honda. Since we work primarily in the .NET stack, I've never really picked up PHP or used MVC (event the Microsoft flavor). I am interested in working on some xenForo Add-On's that I have in mind, but I would like to at least get up to speed so I can conform to PHP best practices as much as possible.

    While I do write quite a few desktop applications, I also write ASP.NET web applications, so I am familiar with the web design side of things (HTML/CSS/JS/jQuery, etc.).

    So, if you were starting over with PHP, where would you start to learn a bit if you had a programming background? I am assuming most people use Eclipse and the PHP add on as an IDE?

    Also, if anyone has some good references for learning MVC and inversion of control, I would appreciate that as well.

    Thanks,
    Shaun
     
  2. Blandt

    Blandt Well-Known Member

    Hey Shaun .. I'm in the same boat :D I'm trying to jump the fence over to PHP from C#

    I have picked up few books ... and .. well.. PHP is not a kiddie script anymore (Sorry .. but this is what most people I work with think of php :oops:)
    you got namespaces, MVC, libraries :eek: ....
    and not only PHP, you have to start looking into MySQL as this here is nowhere near MSSQL ...

    As I said I picked up some materials, I'll be starting a site for this purpose, where I post as I go along the material ... I'll keep you posted ;)
     
  3. Jeremy

    Jeremy XenForo Moderator Staff Member

    Personally, I think the best way to learn is to look at code. I feel reading books is just not as helpful. I learned PHP via vBulletin. I read their code, attempted to figure out the logic, then I broke it to see what did what and such. :) I still do that on a week-to-week basis with things. For example, the Shorter_URL class Cezz and I wrote, when we were discussing it, we wanted to have it load everything dynamically so it was a simple function call. We had absolutely no idea how to do that (we ended up using XenForo_Application::autoload('ClassName');, in case you were wondering), but without knowing that... I delved into the actual code and traced how some of the functions created dynamic classes without a require() in them... and I learned how MVC stores everything and where to look if I know the class name. :) Or the class name should be if I know the file structure (Convert all _ to / and you get your structure, and vice versa you get your class name... and when it ends, add a .php / remove the .php and you get the file / class name again). Real examples help rather than this:
    PHP:
    class foo
    {
    function 
    a()
    {
    print 
    'hello';
    }
    }

    class 
    bar extends foo
    {

    function 
    b()
    {
    $this->a();
    print 
    ' world';
    }
    }
    That explains nothing to me... but if I can see it all working together, it clicks. (PS - sorry for bad formatting... this really doesn't allow for that and I wasn't launching coda for that)...
     
    Blandt likes this.
  4. Blandt

    Blandt Well-Known Member

    You are correct ...
    BUT
    We are (I am at least) use to certain things and ways of doing business it's tougher for us actually to learn (adapt) :D ....

    MySQL is no ADO.NET :D
     
  5. ragtek

    ragtek Guest

    MySQL != ADO.NET(you are right;) ) but you can't compare this 2. You can connect your application to an mysql db with ado.net ;)
    MySQL is the Database and ADO.NET is a "library" to connect and work with the database;)


    As a .net developer, this could be interesting for you => http://phpdataservices.codeplex.com/ but not for xenforo;)


    The problem with king kovifors way is, that you see how things are working, but you don't know why;)

    I think we had this discussion:

    class Foo
    {
    function foo(){}
    }

    vs.

    class Foo
    {
    public function __constructor(){}
    }


    Reading code from applications is a nice way, but if you don't know the IMPORTANT basics, you will never understand it completly.

    My next tip is, that when you start learning coding, you should use an NORMAL editor and no IDE with Autocomplete. You should use your brain, and learn "debugging", instead of letting the IDE making the job for you.

    After some weeks, when you know how things are working, you can start using a IDE.
    IMHO no IDE is the best...
    I would check 3,4 different editors, to see which one is the best for YOU.
    I know there are many different blogs/threads where somebody say "USE ZEND STUDIO/Aptana/Netbeans/Eclipse" ITS THE BEST!!!!!!!!!!!!!!
    If you would do this, you would have to change your editor every 2 weeks;)

    I've used Zend Studio, Eclipse and now i'm working with Netbeans for long time and i'm happy with it.
     
    Blandt likes this.
  6. Blandt

    Blandt Well-Known Member

     
  7. Shaun Mason

    Shaun Mason Active Member

    There is an ADO.NET wrapper for virtually everything.=) I know personally I have used ADO.NET with MySQL as well as SQLite (which is pretty awesome for local stuff, BTW).

    I need to learn the basics, how to call functions, how to pass variables. I really am a PHP newbie. I've written a couple small PHP pages (simple inline stuff), but I need more seasoning to actually write good OOP code. Either way, I am a huge proponent of you should challenge yourself by learning new languages and paradigms.

    That's how I started with C#/VB.NET. I actually left college as a Computer Engineer, so my background was Assembler/C/C++, but once I wanted to actually write apps I taught myself C#/VB.NET and Java. From there I transitioned to some web design work and learned how to develop in that environment.

    I guess branching to PHP feels like the next challenge for me. The syntax is very much like C, so I am sure I will get it down.
     
  8. Blandt

    Blandt Well-Known Member

    I never left college :D :D
     
  9. Shaun Mason

    Shaun Mason Active Member

    Meaning you didn't attend, or are still there?
     
  10. Blandt

    Blandt Well-Known Member

    Texas A&M still there ... few loans I need to work out :D So I'll be there for some time
     
  11. Shaun Mason

    Shaun Mason Active Member

    I have a couple of buddies who were Aggies.
     
    Blandt likes this.
  12. Blandt

    Blandt Well-Known Member

    :) Yep.... I don't even think I grew out of it :D
     

Share This Page