WordPress PART 1: Learning PHP for WordPress

If you want to be a good programmer, whenever you have half a reason, learn a new language.

It’s been a while since my last blog post.

The reason for that is that I’ve taken up a new interest and started a new adventure. I have started freelancing and I’ve noticed how many clients require WordPress websites. So I’ve used the past month to learn PHP for WordPress development. In this post I hope to share how I got started with PHP and, hopefully, how you can do it too.

Attacking PHP from my Python Background

If you know Python, PHP will be very easy to pick up. But it will also be a little frustrating. Python uses indentation to mark block structure. Its syntax is simply elegant. PHP syntax, with its curly braces and semi-colons, to me at least, looks much more like JavaScript than Python.

If you search “Python vs PHP” you will be confronted with literally thousands of articles skewed in favour of one or the other. I dislike that. Programming languages are only tools, people. Each tool has a job it is best suited to do. And, since my end destination is WordPress, I obviously need PHP. Both Python and PHP are interpreted, high level languages. Both have large, passionate communities. Both are easy to learn and the jump between the two is not that big. Python is multi-talented. PHP is still the lingua franca of the web.

You can certainly start WordPress theme development without much PHP knowledge, but I like doing things properly. Personally, I needed to be sure that I had some foundation in PHP before I even looked at the WordPress Codex.

Where to Start

Here and here are excellent articles which explain how to setup a WAMP(Windows), MAMP(Mac) and LAMP(Linux) Stack, which is needed for local PHP development.

Note for Windows Users: You might find that the WAMP icon in your system tray stays orange. If you already have MySQL running as a Windows Service you need to switch it off before you start your WAMP server. In the Control Panel type: services.msc. This opens the list of Services. Scroll down to MySQL, select and click Stop the service.

Below are some of my favourite, free(of course) tutorials for getting started with PHP.

1. Codecademy

Whenever I want to learn something new, Codecademy is the first site I check. They have a great PHP course, so that was the first thing I did. It is important to understand that one Codecademy track does not a PHP programmer make, but it is an excellent intro.

2. Home and Learn

They have an very good online course. If you want to follow along, you’ll need to download the course materials from here.

3. PHP The Right Way

This is another online tutorial. They also have an nice list of additional resources.

4. tutorialspoint

For most of their examples you will find a Try it option, so you can test your code.

5. learn-php.org

This is a free, interactive PHP tutorial if you prefer less theory and more doing.

Also be sure to check out php.net where you’ll find the official docs available for download.

Past the Theory

The tutorials above will give you a nice foundation in PHP theory. I don’t know about you, but I learn best when I actually create something. Now, one of the tiny issues I have with PHP is the endless selection of frameworks. Laravel, CodeIgniter, CakePHP, Symfony, Zend Framework 2, Phalcon, Yii, Aura and the list goes on. If you search for PHP app tutorials you will find many by many developers, each pushing their own framework of choice.

I do not need any of these for WordPress. So, I found a wonderful 6-part tutorial series on creating a simple CRUD(Create Read, Update and Delete) app with just PHP and MySQL. The app creates new staff with the the following details: name, position, joined date and bio data. You’ll also have the ability to view staff details, update staff details and as well delete staff from the database. It’s very simple, but it means actually writing PHP code, which is exactly what I was looking for. Try it here.

Good Start. You’re on Your Way

I continue learning more about PHP. If you have been doing this coding thing for a while, you well know the learning is never done. In the next part, I will introduce you to the wonderful, wonderful world of WordPress. After that we will be customizing existing themes. I will also show you how to create themes, not from scratch, but using a starter theme.

Until then, as always,

Happy Coding!

Leave a Reply

Your email address will not be published. Required fields are marked *