The Best Way to Learn PHP
basix

The Best Way to Learn PHP

Tutorial Details
This entry is part 3 of 4 in the The Best Way to Learn… Session
« PreviousNext »

Learning something from scratch is almost always an arduous affair — you simply have no idea as to where to start, or not to start, to kick things off. I loathed learning about the idiosyncrasies of C++’s syntax when all I wanted to learn were some darn programming concepts. As I’m sure you can agree, this is a less than ideal situation.

This is where the Nettuts+ “The Best Way to Learn” series comes into the picture. This series is intended to be your blueprint, your road map, your plan of action for learning your topic of choice! You don’t have to worry about finding the best resources, sorting out the bad ones, and figuring out what to learn next. It’s all here. Just follow it, step by step.

Today, we’re going to figure out the best way to learn PHP.


Assignment #1: Disregard the Naysayers

If you’re reading this, chances are that you’ve googled a lot to decide which language to learn and how. And without a doubt, you must have run into a ton of articles about how language X is so much better than PHP and PHP is going to die through obscurity soon.

Haters gonna hate!

As the popular saying goes, haters gonna hate! PHP has been at the helm of the web as you know it and that’s for a very good reason. It’s a mature language, has excellent documentation and a massive number of learning resources along with a great variety of utilities built around it.

And let’s not forget the sheer proliferation of hosts and frameworks PHP has spawned. Like Heroku like hosting? Don’t worry, there are a number of excellent options for PHP as well!


Assignment #2: Install PHP through [X]AMP

Tut image

You could just install PHP but it gets quite boring without a server and some sort of database to play around with. And as a beginner, it’s not really trivial work to get all of these installed and configure each to work with the others without issue.

This is where you grab a package such as XAMPP. These life savers typically install Apache, your web server, along with mySQL, a database system along with PHP significantly cutting down on set up time.

Bonus points if you’re the code monkey type and install everything by hand.


Assignment #3: Dive into PHP!

Before I send you off to alternate sources for PHP enlightenment, let me first refer you to our very own series for absolute beginners from none other than your favorite editor, Jeffrey Way.*

In this series, everything from installing PHP to variables, from functions to working with SQL are covered. They maybe more than two years old but gosh darnit!, they’re still extremely relevant.

*who is also painfully humble so shoosh and stop making him blush!


Assignment #4: Sign up with Khan Academy and Lynda

Tut image

Khan Academy may sound like an odd choice since there are no PHP lessons in there but trust me, it’s a good choice. What you can’t find in pure PHP, you can find in the basic of programming. For example, if you’re new to the entire programming hoopla, this is a great place to start.

Another great place to start is Lynda. Here at Envato we have immense respect for those teaching there — the content is usually top notch and cover their topics well. And they cover a vast range of topics as well. If you need a specific lesson, this is where you should begin.


Assignment #5: Read a Few, Good Books

The videos should give you an very good springboard, but, hopefully, hungry for more knowledge. The below books should give you a more elaborate introduction and lots of varied topics for you to devour.

If you feel bored reading the initial portions, good, just skip ahead to the portions where your head hurts.

Nettuts image

PHP Solutions: Dynamic Web Design Made Easy

Author: David Powers

“So why another PHP book? Well, not everyone who uses PHP is a programmer. PHP is the most common dynamic web language used by designers, if their web sites require dynamic functionality, and there are hordes of novice users who want to set up dynamic web sites.”


Nettuts image

PHP for Absolute Beginners

Author: Jason Lengstorf

“PHP for Absolute Beginners starts at the very beginning stages of web programming, showing even the most inexperienced web developer, through examples, how to build a basic content management system. The book dives directly into writing web applications with accompanying explanation rather than explaining elements of the language and then showing examples.”


Nettuts image

PHP Cookbook

Author: Adam Trachtenberg

“PHP Cookbook has a wealth of solutions for problems that you’ll face regularly. With topics that range from beginner questions to advanced web programming techniques, this guide contains practical examples — or “recipes” — for anyone who uses this scripting language to generate dynamic web content.”


Assignment #6: Create Something Simple

This is the perfect time to build something simple with your new found knowledge.

Alright! With all those information swirling inside, you should feel like a rockstar. If not, don’t worry, it’s completely normal. Talk to me later so we can share notes about how daft we feel.

This is the perfect time to try and build something simple with your new found knowledge. It’s best to not try to build something too complicated and fail though — it’s a lot more disheartening than you’d think. Imagine being rejected for the first time. Now multiply it by a few hundred and you’ll be close.

Since you’re just starting out, play it safe and build something absolutely basic like a CRUD app. Nothing major — a few inputs and an ‘uncool’ table to display saved results. This tiny exercise will test your knowledge of a lot of PHP basics including the much vaunted ‘interfacing with a database’ skill.


Assignment #7: Create Something a Little More Complicated

Feeling better now? You should! You gazed upon where there was naught and said ‘This won’t do!’ and created something from scratch. If it were me, I’d be pumped. Let’s use it to extend our knowledge a little more.

While a simple CRUD app is a great start, you’d ideally need more complicated. A simple login/user system is absolutely great for this.

You get to learn how sessions work, how basic authentication is done, how to implement basic security measure and a ton more.

Note: If you’re in need of a little guidance, start here.


Assignment #8: Try out a Lean, Lightweight Framework

Tut image

At this point, after creating a non-trivial system, you probably have noticed how repetitive some of the work is. Why the heck do you need to write your own sessions class or work on hashing passwords yourself? The answer, my friends, is to go with a lightweight framework.

A framework abstracts a lot of the repetitive, boilerplate features in your typical application thus freeing up your brain to actually getting things done.

Note: Not to toot our own horn but we have an immensely thorough session that covers almost all of the important parts of CodeIgnier, a very lightweight, yet powerful framework. If you prefer Kohana, we do that too!


Assignment #9: Try out a Full Stack Framework

Tut image

Now that you’ve been with a lightweight framework, you can now check out the alternate path — a full stack framework. A full stack framework typically ships with a lot more features including code generators, ORMs and an inbuilt server. An excellent choice would be CakePHP — the PHP equivalent of Rails.

The reason you need to check these out later is because there is a lot of ‘magic’ going in these frameworks. Without a solid understanding of how lightweight frameworks work, it’s hard to really dig into the better featured ones since you’ll mostly be lost and won’t understand how things work.

Note: For a quick look on CakePHP, start here.


Assignment #10: Build Something Awesome

With all that information behind you, giving you Indiana’s swagger, now is the time to build something truly awesome. This is the final destination for PHP nirvana — and the choice is up to you.

So what exactly should you be building? Here are a few ideas:

  • A blog is always a safe option. There are a ton of open source solutions for you to get inspiration for the software architecture and the functionality requirements are unambiguous.
  • It’s a little old school but a discussion board is another excellent choice. Moderator rights and post counts, ahoy! If you need a little guidance, this tutorial is a great place to start.
  • Or if you’re too hip for any of these, build yourself a project management application or even just a todo list. They’re always fun to build and you’ll almost always end up using it personally.

Of course, there are just suggestions. No one is stopping you from building a multi-user, realtime chatroom or a service which receives input from random internet strangers and lights up stuff in your room. No one’s judging, go crazy!


Assignment #11: Advance into Development Eliteness

Development is as much about the workflow as much as it is about the code.

Development is as much about the workflow as much as it is about the code. Recently, a typical developer’s workflow has been massively improved by version control as well as platform as a service solutions.

Version control, as expected, frees you up from having to manage revisions manually while PaaS solutions save you from having to do a lot of sys admin work just to get your app to scale.

Resources for the latter are a bit hard to find but here is an excellent screencast on getting started with Git.


Assignment #12: Get Involved and Be Up to Date

New techniques and tools are being introduced everyday.

The web development industry is rarely in a state of equilibrium — everything is changing all the time. New techniques and tools are being introduced everyday and it’s important that you not only read about them but also start contributing.

Find a little glitch in some framework? Submit a patch. Added some new functionality? Patch away! These not only earn you good karma but also valuable points on your resume.

And, oh, about the keeping up to date stuff? Subscribe to our feed and follow us on Twitter and I promise you’ll know all you need to know!


Assignment #13: Keep an Open Mind and Explore

Tryruby

Even though that you are a master of the PHP domain, you can’t afford to, or shouldn’t, rest. PHP is a grand language but that doesn’t mean that it does absolutely everything perfectly.

There is an ever increasing number of new languages out there each adding their own spin to solving a very specific problem that you simply can’t afford to miss out on. And learning something new something doesn’t really wipe out knowledge gained earlier does it? Well, except Star Wars, of course. Those new movies were a crapshoot.

Ruby, Python and Clojure are some of the languages that I’m constantly amazed by and I think they deserve your attention as well. Neither of these languages are necessarily ‘better’ than PHP but each of them do things their own unique way and you owe yourself a chance to take a look and find out whether that approach is for you. While we’re a bit low on Clojure related content, we do have excellent tutorials on Ruby and Python right here.


Conclusion

Well, this is the end of the road, partner! Hopefully, this plan can help you become a PHP master and, indeed, take over the world.

If you feel that I’m missing some obvious resources here, feel free to yell at me in the comments section below and I’ll update this article whilst crying silently. Thank you so much for reading!

Siddharth is Siddharth on Codecanyon
Tags: basixPHP
Add Comment

Discussion 111 Comments

Comment Page 1 of 21 2
  1. Devypt says:

    Nice,Very logical strategy.

    • Devypt says:

      But i think Zend is the good example for full stack framework.

      • Siddharth says:
        Author

        Zend can be overwhelming, even for experienced devs. CakePHP is a nice alternative.

      • Bjoern says:

        I must agree – Zend is a much better and much more professional alternative to CakePHP. CakePHP is just horrible and in my opinion totally outdated. However, it has a nice Bake feature,

        Nonetheless, the author answered that comment also appropiate. Zend is a very very difficult and very advanced framework. I have been working with it for 5 years and everyday I am discovering new features and little things with Zend.

        Maybe an alternative between these two is an appropriative answer. But I think everybody needs to find the answer for him/herself as it is also a question of style and I think choosing a framework needs to be very carefully considered.

        But when you get to the point, that you need to use a heavyweight world champion PHP framework you should have had some good experience with frameworks and the whole idea of it as well.

        Anyway, as an experienced PHP developer I like to read this article and appreciate it as it was not always easy for me to get into PHP. Even though, it is the most widely “spoken” programming language it is very difficult to find VERY GOOD teaching material.

      • briedie says:

        Kohana!

      • @Bjoern

        I don’t see how Zend is a much better and much more professional framework than CakePhp is. What makes it more professional? Because it’s more complex and takes longer to learn?

        I’m sure Zend is a great framework but, can a developer build something with Zend that s/he couldn’t have built using CakePhp?

  2. agrant says:

    This article is great because it gives anyone curious about PHP some direction. I myself still find it interesting to learn about. Joomla is a decent framework to mess around with PHP, however you can’t rely to heavily on online tutorials. The inline code changes from time to time but you’ll knock it out after studying the framework. This dynamic language guides you into learning MySQL database. Happy coding!

  3. edwinhollen says:

    You suggest installing XAMPP, but I have found WAMP to be much, much, better in terms of ease of use.

    WAMP also falls into the family of -AMPs, alongside it’s Mac companion, MAMP.

    • pffft…

      $cF == 1;
      if($cF === 1) {
      echo ‘ColdFusion is WAY better than Python’;
      } else {
      echo ‘Why aren\’t you you using ColdFusion, it is way better!’;
      }

      j/k, this is a total joke, but, on a serious note, how can you say Python > *? it is a matter of what is best for you and what you know. statements like that and my joke are totally ignorant. that being said, the author made some great points about learning php, and I would have to agree with them, accept for using cake (i prefer zend). I also write a few different languages, but, i would not say any of them are better than the other. open your mind a bit man. :)

  4. Matt says:

    Loving this “Best Way to Learn…” series! Doesn’t seem nearly as daunting with the path you guys lay out to get started. Can’t thank you enough!

  5. Oscar says:

    You miss Assignment #13: Learn a real framework like Symfony2 XD

    No, I’m not a troll. But it is baised to say (you did in a comment) that Zend can me overwhelming. There are tons of reasons (developers) that says it is not.

    I’m a S2 guy.

  6. Dels says:

    what most people usually didn’t do before they learn to use framework is learn how to use OOP in php, basically they learned how to create CRUD using procedural programming (and guess what… no mysqli or PDO, just the old mysql)

    • Olaf says:

      Right, you need to learn OOP concepts before you start using a framework. Use a framework or class because someone has written the code before and not because you can’t write it on your own ;)

  7. Vamsi says:

    Good post,

    Another way to learn php is by reading php.net and reading User Contributed Notes

    http://php.net/manual/en/index.php

    also, for example if you want to know more about echo

    you can just go to php.net/echo

  8. Paul says:

    Nice tips for someone new to get started with PHP.

  9. Lukasz says:

    Installation and configuration of apache+php+mysql by hand should be another “assignment”. It’s the best way to understand some security issues about, for example, sessions.

  10. Kenny Ledet says:

    CakePHP….the rest of the tutorial is great but CakePHP….

    How about symfony2, easily a much better framework.

    Do you guys just not want to look like bandwagoners?

  11. I enjoyed having all these relevant links in one place. I’ll start with them and thanks for staging out PHP learning path.

  12. Vordreller says:

    Wasn’t there a tutsplus article several months ago, declaring CakePHP the slowest of all the current frameworks?

  13. redwall_hp says:

    I have the exact opposite issue. I’m very much used to PHP’s C-like syntax. As a result, I’m bothered by Python and Ruby’s bizarre syntax idiosyncrasies. No curly braces, tab-delimited functions, etc..

    • larzconwell says:

      I’ve been using Ruby for a while now and i learned c++ a while back as well so im used to the complete OOP and then the C like syntax, so now im hooked on using OOP languages for web based, and well c++ for desktop applications. So i tried learning PHP and i couldnt get the feel of it because the c like syntax. So im staying with Ruby and RoR/Sinatra

  14. Well structured points/nuggets/assignments. I also agree that Zend could be overly complex sometimes and so CakePHP is a better alternative to a full stack PHP framework. Zend is excellent though once the basics has been understood.

    Thanks Again!

  15. Great write-up Siddharth! This is a very similar strategy to what I observed, although I read some books a bit earlier on.

    The Sitepoint book Build Your Own Database Driven Website is also a really good resource, helped me with getting started and to the point I am today.

    Another great lightweight framework (very fast, easy to work with, and with documentation to rival Codeigniter’s), is Laravel, which I’ve fallen in love with coming from a Codeigniter background.

    But, I’d recommend that you add for people to at least learn the concepts of OOP, and maybe practice them a bit, before they dive into a framework. It’d really add to their understanding and help them more in the future.

    Thanks for the great read!

  16. Jesus says:

    Assignment #9 should be yiiframework http://www.yiiframework.com/

    Seriously guys, give it a try. You’ll never come back.

  17. Alex says:

    As a junior front end developer, PHP is on my list of things to learn along with Javascript. Would you recommend starting with Javascript before getting in to PHP though?

    • larzconwell says:

      I defiantly think you should look into Javascript first before PHP so you get a feel of something slightly dynamic. And i dont mean a JS framework like jquery, learn pure JS. Then when you try PHP you will actually notice a very similar feeling. Especially since they both share some of the same syntax.

  18. Aslam Doctor says:

    Awsome tutorial. I am already on the Assignment #8: Try out a Lean, Lightweight Framework

  19. Ilya says:

    Nice, I like this series.

    Could you do something similar for Java too?

  20. Khalid says:

    This is awesome. I’ve been working for years with HTML and CSS. Now I want to learn PHP (and JavaScript) to expand my knowledge, but I didn’t know were to start. Bookmarked!

  21. Imogen Pond says:

    If you don’t want Perl to be installed as part of the package I’d recommend using WAMP, (or LAMP if you’re a Linux user like me). Great introduction if you’re new to PHP! Thanks.

  22. Boabramah Ernest says:

    I would also suggest that after getting acquainted with wamp or xamp as a beginner, try to understand how php, mysql and apache work together so that when it comes to changing the default configurations of these prebuilt servers, it would not be difficult for you.

    Also learning another language will help you to understand why php behaves the way it does.

    Get into doing lots of projects and learn how web applications are built nowadays using the MVC pattern before trying your hands on frameworks.

    if you decide to use frameworks, pick the ones that can help you do something quickly to gain the confidence.

  23. SonyC4 says:

    Very Good and Useful Article,
    Thank You Very much Sid ;)

  24. Lucas Rolff says:

    For some time ago I bought the “PHP For Absolute Beginners” And I really liked the book, until problems started to come.. on Page 240 or so, you’ll run into a huge error, that isn’t able to be fixed, even the code source on apress.com isn’t working. Errata isn’t there because Apress updated their site, they’ve promised me, it would soon come back, but until the Errata comes back, Don’t start read that book.

    – Lucas

    • Russell says:

      As someone new to PHP (at “assignment #5″ stage) I’ve been looking into books to further develop the little I know, and I’ve read similar grumbles about the “Absolute beginners” book (poor/outdated syntax examples, etc.).

      If anyone has any other suggestions, I think us little ‘uns would really appreciate it – I’m looking at Vikram Vaswani’s “Beginner’s Guide” now as an alternative to “Absolute Beginners” – hopefully there won’t be too many issues with this.

  25. Both the “Absolute Beginners” and “php essential” guide are a must buy and are regually on my desk. I haven’t read the book by David Powers but can only assume is great as well.

    I’ve never been a fan of frameworks they can be overly complex for a lot of projects, starting from a blank page can be slow but is my preferred method of working.

  26. Aria Minaei says:

    I have a habit of taking shortcuts to learn stuff.

    Sure, there are conventional, proven ways to learn something. But alternate methods — if used correctly — could give you huge benefits.

    Anyway, I would suggest starting with the basics. You know, the syntax, the concept, stuff like that.

    Once you have done a few small projects and you are comfortable in coding and solving common problems — doesn’t matter if your code is all spaghetti at this point —, it’s time to start taking the shortcut.

    Simply take a well written piece of code, start your IDE (definitely recommend Netbeans), fire up xdebug, and start learning the code, line by line.

    For those of you who don’t know how it works:
    When you run your php application with xdebug’s debugging enabled, the php interpreter stops at the first line of the code. Using your IDE, you have the ability to step into any line, step into different functions, and also see all the variables in the current scope and even the superglobals. So you can see exactly how the application works. It’s so much faster and better than reading the code and running it in your head.

    I recommend taking a sample application based on Zend Framework (you can find many in zendcasts.com), and debugging it line by line. There are so many common and uncommon problems already addressed in full-stack frameworks like Zend. For many of these problems, you can’t even find a tutorial online. I can’t tell you how many hours I have searched for how to get things work online, and then finally found it in the code of a framework or an application. Also, these frameworks are built upon best practices. You read their code, and you learn the best practices.

    This is usually how I kick start learning pretty much anything.

  27. David says:

    Great post. I started learning PHP over 10 years ago when I decided that I wanted to build a portal site of sorts. I had a look at all the frameworks of the day (ie: phpnuke) but none of them provided the flexibility that I wanted. Therefore, I set out to build my own framework. It’s a great way to learn everything about PHP as well as develop some good coding habits. Don’t just opt for frameworks, study and build!

  28. dstudio says:

    Are you planning to create some Yii framework tutorials?
    Thanks

  29. Fahmy says:

    what about Data Structures and algorithms

    • Siddharth says:
      Author

      I’m not going to say that you don’t need them. But I will say that as a beginner looking to learn web development, algorithms can take a backseat while he/she gets accustomed to the rest.

      For your normal CRUD apps, an array is all the data structure you need. Once you get beyond the beginner level, things tend to branch out a bit but that’s beyond the focus of this article.

      Thanks for reading!

  30. Tharshan says:

    Nice article, quite informative and well rounded.

    PS – The first two links of the books are the same.

  31. Gvidas says:

    Thanks for this lovely article…I think my mistake was then I didn’t learn php and tryed to build website by self only with basic knowlage..Ofcourse there was only login,register form..nice,working..but thats it…I have a lot ideas,but there was no knowlage how to make them..So thanks again for this article,now i know what i need to do..I need learn php until I will be able coding like speaking..

  32. first of all thanks to all envato..you people are doing same thing for web and design industry what bill gates done for computers..

    i learned about web design..what i know all from nettuts and your other sites..

    in short..

    i love to see same post about simple things like css, html, and one on whole web site design..

    i like to see a post which give a idea to a absolute starter which way to go..when i started i am clueless..wasted time on useless things..so it will help someone..

    also if it will suggest how to apply for earning..like may be one know php..and have good knowledge of core php..know one or two framework..but didn’t know basics like css/html..and don’t know any cms system..then getting job is not hard in my country india..but staring your own work is not easy..

  33. Alan says:

    I don’t get it, where is the article?

  34. I’d like to say that using a framework is really detrimental to learning PHP. I had been using PHP for nearly 4 years before I had used my first framework, and I have to laugh at some of the ridiculous questions I see in the help forums. If a person doesn’t know how to work with arrays, loops, and operators, you they have no business checking out a framework. A developer should consider a framework to be like a shortcut, but if the long way isn’t known, then he/she will certainly be lost.

  35. Ayub Lin says:

    Nice list of references, and don’t forget to download the PHP Documentation http://www.php.net/download-docs.php :)

  36. Deven says:

    Nice article for beginners, I will also recommend the W3schools ( http://w3schools.com/php/default.asp ) to learn and get basic clear out for beginners – Thank you

    • PKW says:

      I agree W3Schools is great. I’ve been a professional programmer for a long time and have used PHP professionally for several years. I still go to the W3Schools site first for simple questions about PHP, HTML or CSS.

      On the topic of frameworks, I use symfony, but find it very large and I’m not a big fan of ORMs even though I’ve contributed fixes to Doctrine-Oracle.

      I am currently considering looking into CodIgnitor and ZEND.

  37. cory says:

    Good tutorial.
    I’ve never understood the hate for php, in my opinion all languages have their place. For instance with Ruby, for most websites that is overkill, especially with the increased price in hosting.

  38. Oscar says:

    Wamp Server is easiest to install and use than Xampp

  39. SmashingFree says:

    Awesooooome! great! I’ve been waiting for so long for article like this. Thank you Siddharth..

  40. Mr. Lee says:

    This was a good post. The one thing about PHP that falls flat is the docmentation supplied on the php.net web site. Beginners should beware of that site. The information found there is hit or miss, mostly miss. Instead of trying to help someone learn a particular function they contributors usually try to outdo each other with ridiculous gyrations of how to do things the most obscure way.

    Buy a PHP book or two instead. Once you get into PHP try the book Object-Oriented PHP, Concepts, Techniques, and Code by Peter Lavin; NoStarch Press.

    • Mike Henken says:

      I think this cannot be farther from the truth. Part of learning the language is figuring out why some those
      user-contributed examples work, and why others do not.

      It also provides valuable input of the different styles of programming with php..

  41. Oscar V says:

    Thanks for putting together this road map to learning PHP. I’m not a big PHP developer but the PHP work that I’ve done has been real fun.

  42. XuDing says:

    Thanks for your insightful opinions.

    However, I think there is one more assignment to add here, which is to learn some programming patterns, that is something more advanced before you try to program a complex application. Programming patterns will also help you understand how framework works and so on.

  43. Bill says:

    I’m a lazy guy, so I always watch videos to learn a programming language, which is fast but not detail enough. I’ve been looking for some books for php, but they didn’t goes as detail as the one you suggested PHP Solutions: Dynamic Web Design Made Easy. Thanks NET TUTS. Put more books suggestion!!!

  44. Keshav says:

    Really Really very good article..

    one more TIP : ask and solve your problems on http://www.stackoverflow.com and continue read the latest problems regarding PHP and mySQL, you will surely increase your problem solving skills.,

  45. Amol says:

    There are lots of good tutorials on Netttus+ about Lightweight frameworks like Codeigniter. But I hardly find any tutorial on full stack frameworks

  46. Dinesh says:

    Can i run these frameworks on windows 8?

  47. Tony says:

    Great article. I will definitely keep it close by as I begin my new journey with PHP. Thanks

Comment Page 1 of 21 2

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.