For New PHP/MySQL Developers: Where to Start
Posted on 25. Feb, 2010 by Kayla Knight in Coding
Every developer has their programming language of choice, and for many that choice is PHP, with a MySQL database. There is no doubt that this coding-combo is among the most popular option for creating web applications, as it is used for many of the top applications today (Wordpress, phpBB, Drupal, and Joomla to name a few). Also, many new clients request PHP-based websites or applications for new jobs every day. Any aspiring developer knows that learning PHP and MySQL can lead to great opportunities down the road; the popularity of the language isn’t going away any time soon.
Despite many of us understanding how learning the language can help us professionally, learning PHP/MySQL can be difficult. This is especially true when going at it alone. In this article, we’ll go over what is most essential when getting started in PHP/MySQL, and what one can do to learn the language well enough to win over clients.
1. Install a Server for Working with PHP Locally
In order to get started with PHP development, one needs to install a local server first. This will allow one to develop PHP Internet applications even when offline, and locally on their own computer. This speeds up development dramatically, and is essential for the learning curve. In addition to making it easier on you, the developer, installing a local server is a skill that needs to be learned in itself.
I personally use XAMPP, which is cross-compatible and well-documented. XAMPP is a popular web server package (Apache), which includes phpMyAdmin, MySQL, and interpreters for scripts written in PHP and PERL. There are a number of tutorials available for installing XAMPP, more specific tutorials for installing Wordpress or other popular platforms on XAMPP, and documentation concerning settings, troubleshooting, and more.

There are also some alternatives including WampServer 2 and MAMP (Common for Mac users).
Check out some of the resources below for finding out more and setting up a local web server:
- Installing XAMPP on Windows (There are guides for any OS, just do a quick Google search)
- How to Install XAMPP (Windows & Mac installation guides, although not as thorough)
- Installing WordPress Locally on Your Mac With MAMP (for all those focusing on Wordpress development)
- Installing WordPress Locally (Another MAMPP/Wordpress installationĀ guide, however very thorough and well-explained)
It can also help to do some research on web servers, different options, their benefits, and more just for the sake of becoming a better web developer. It definitely isn’t the ‘fun’ side of web development, but learning the technical side of things can help one to understand PHP/MySQL better, as well as web development in general.
2. Understand PHP-Database Interaction
Many new developers will want to get into PHP and MySQL, not really understanding why they are choosing the technology in the first place. PHP is so useful because of its easy interaction with a MySQL database. Understanding that interaction and when and how it can be effectively used is the first step to creating great web applications.
Take a shopping cart for example. Nobody creates a shopping cart in PHP for the sake of using PHP. It is instead PHP’s ease of use when it comes to updating, deleting, or adding new data to a database (such as products, prices, customer information, etc.) via MySQL.
Through PHP, using a MySQL-inspired function, adding data to a database can be as easy as:
<?php
// Connect to database, start sessions, etc.mysql_query(”
INSERT INTO products (id, name, description, price)
VALUES(’sku-194923′, ‘PHP for Beginners’, ‘A PHP book for absolute beginners.’, ‘29.95′ )
“)or die(mysql_error());?>
As a practice assignment, create a list of application ideas where PHP and MySQL would be a good idea for its development. Describe, either in psuedo-code English or in code, how PHP would interact with a MySQL database, and how it could interact with a basic HTML page and user interface to meet the goals of application. What types of information would need to be saved dynamically in a database for the particular type of application? In what ways should the information be accessed and interfered with by the user to create a dynamic web application?
3. Learn the Basics in the PHP Language
Where most people start is here: learning the basics of the syntax. This includes if/else statements, switch statements, functions, and for the eager and ambitious, object-oriented syntax. Needless to say, this is an essential step in learning PHP and MySQL, but most of learning a programming language is learning the theories and best practices. Understand first how to set up a PHP application in theory and the rest can be handled by looking up syntax as needed.
I think the best way to learn syntax is to just do it, rather than read through and study it. Think of a small sample program one could create (without looking up a tutorial for how to do is specifically). Start small, like a simple calculator, and work up to something like a simple content management system. Try doing it at first without the tutorial, but looking up syntax where needed. Then, read through a related tutorial, and examine best practices, fix errors, and learn from your own mistakes.
Tizag is a great place to start for this. There are no project-specific tutorials to learn from, but rather just how-to’s on how to accomplish general practices in PHP and MySQL. For example, there are no tutorials like, “How to create a basic log in script with PHP,” but rather information on how to save information to a database, check information from a form, and how to save session variables. All of these components put together can create a log in form, but it will be you that is putting it all together to create the log in script, instead of copying and pasting code.
4. Know how to Debug PHP/MySQL & Handle Errors
It’s easy to give up learning a new language when constantly running into errors. Especially when going at it alone, it is especially difficult to overcome obstacles. Error handling is essential to any programmer, but even when just starting out, get a good grasp of at least some basic error handling. This way, when encountering a problem, it can be ten times easier to figure it out.
Check out the following resources for debugging in PHP:
- Debugging Techniques for PHP Programmers
- PHP Debugging Basics
- Debugging PHP with Firebug and FirePHP
- Debugging in PHP (PHP Manual)
Also check out best practices for error checking in PHP, which in return can help with debugging along the development of an application:
- PHP Error Handling and Logging (PHP Manual)
- W3School’s PHP Error Handling
- Error Handling in PHP: Coding Defensively
Always be sure to set up specific and custom made error message within the development process to be sure you know what exactly the problem is. Within the learning curve, this is a great way to learn from regularly committed mistakes, and fix them in the future for faster development.
5. Study Application Design
With a mix between HTML, PHP, MySQL, and even other languages on a webpage, a PHP application can quickly become unorganized and eventually confusing. Staying organized is the key to being a good developer. By doing so, not only will it make it easier on you, the coder, but also for your client and anyone who may need to maintain the code.
For example, web designers and developers who have only studied design, XHTML, CSS, and the other basics of website development already follow basic best practices for organization and website structure design. All stylesheets, by best practice, are located in a /styles or /css directory. The same goes for external JavaScript files in a /js or /scripts directory. Main pages are located in one directory, and sub-pages can be better organized.
Beyond organizing where files should go, there are also best conventions for naming files, and for how the code is organized within those files. JavaScript implementation is usually best put right before the footer (with the link to the external JS in the header). We all learn at the beginning that external stylesheets are appropriate for organizing code, rather than placing all of the CSS, JavaScript, and XHTML into the same file and repeating that that information in each page. Simply sharing external files between multiple pages is more efficient.
The same goes for PHP application development. One common best practice is to put all of an application’s classes into a /classes directory. There may also be an /includes directory. Functions to connect to the database would all be in one class, and functions that deal with a user would be in another.
I could go on and on about my own application design and best practices, but that’s for a later date. Below are some resources to check out what other developers do, and what anyone should do:
- Five Common PHP Design Patterns
- What PHP application design patterns do you use?
- Introduction to Design Patterns Using PHP
It can also be helpful to look up more advanced tutorials for PHP application development, and examine how that developer is choosing to set up their application, and any best practices they may be using. Or, download an existing script, and examine it from the same point of view.
6. Study Database Design
Just as important as application design is on the PHP end, the MySQL database structure is just as important. Organization can speed up development and lead to easier and more efficient maintenance. In database design, there is a concept called database Normalization. This presents the idea that data should be organized in a common way among applications, and these ways have been defined as efficient and as organized as possible.
Check out the following resources for getting more familiar with normalization, database design, and common mistakes when using databases with PHP:
- Five Common PHP Database Problems
- Database Normalization
- An Introduction to Database Normalization
- Peachpit: MySQL Database Design
At least with me, learning how to structure a database and how to navigate my way around something like phpMyAdmin was the trickiest part to becoming a great PHP programmer. No doubt, a good PHP application cannot be made without a good database design behind it. However, learn the theories and best practices, do some practice work, and learning the correct methods can come more easily than you’d think.
7. Find a Favorite Framework
Last but not least, research some popular frameworks and get started with one. I only use a framework for bigger applications, but knowing one will come in handy as being familiar with one is just a part of being a good developer.
I personally use CodeIgniter, and from my experiences it has served me well. Other popular frameworks include Zend and CakePHP. I chose CI because Zend tends to be for much more complex application development, and it seems to have more documentation/tutorials than CakePHP. However, be sure to check out a number of other options, check out a few beginner tutorials for each, and determine which one is right for you.

Shikeb Ali
Feb 26th, 2010
Very informative post… i am really interested in learning PHP and turning my designed layouts into wordpress themes or just doing some coding for making website more dynamic.
Thanks Kayla for the info… looking forward for some more from you… .
Antonio
Mar 18th, 2010
Personally I prefer using Zend Framework. The documentation is very detailed and there is a lot of support behind the framework. It’s also very good for social media integration, and it comes with Lucene so you can integrate search on your website.
The thing I like about CodeIgniter thought is that it’s very light weight and easy to learn. And it has a Shopping Cart class, which is something I think Zend should really think about adding.