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 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
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.
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.
They have an very good online course. If you want to follow along, you’ll need to download the course materials from here.
This is another online tutorial. They also have an nice list of additional resources.
For most of their examples you will find a Try it option, so you can test your code.
This is a free, interactive PHP tutorial if you prefer less theory and more doing.
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,