PHP / MySQL

I make dynamic database-driven websites that are searchable and are tailored to the surfer’s needs using PHP with a MySQL database on a Linux/Apache server.

OOP PHP

When I started coding PHP I began writing the code inline, but soon moved to a more structured OOP (object-oriented programming) style. Using well-constructed OOP gives an application the ability to be updated and changed easily, re-used and worked on by a team of developers. You’re also separating the back-end content-generation from the front-end content and formatting.

I try to keep my code properly written PHP (PHP: The Right Way) and try to minimize loading external plugins and libraries. #perfmatters

Security should always be a consideration. PHP5 enhances the OOP capabilities of PHP so that it is nearer to the OOP of other languages. Some of the PHP5 features increase security.

Current PHP code examples are on my GitHub.

CMS

PHP allows dynamic, database-driven websites to be created such as online stores, blogs and social networks. The main type of websites I write are PHP content management systems (CMS). All my CMS websites are hand-written from scratch without using other frameworks or template systems.

CMS websites can be added to and edited without having any programming knowledge, they are also a lot quicker to update than manually making each HTML page. Plus, when one page changes all pages that link to that page change automatically. Using a template system if you want a re-design or just want to update the HTML it’s fairly easy to switch between different templates, and because one template is used by several pages there are not hundreds of files to alter.

MySQL

Database-driven websites need a database and the database I use most often is MySQL.

If all the content of a website is coming from a database then care has to be taken to minimize the number of SQL calls to the database and to make efficient SQL that is not using too many resources or getting too much unneeded information. Part of that is with the actual SQL scripting and part of it lies in setting up the database correctly with keys and indexes, where necessary.

Careful use of SQL with prepared statements can make a website efficient, quick and secure. Not only do I specify whether an user inputted value is an integer, string or expression in the prepared statement, I also try to make sure it is the right kind of input before it gets to the SQL.

I’m currently using PHP Data Objects (PDO) extension which is built-in to PHP5.

LAMP

I’ve tended to use managed hosting in the past but have stated using the terminal to manage servers remotely on a cloud (HAAS) on Amazon AWS. I’ve used S3, CloudFront, Route 53 and EC2.

On EC2 I have…

  • Set up an instance of AWS EC2 (Ubuntu) and installed Linux, Apache and MySQL on it.
  • Installed a WordPress blog on the space.
  • Set up a virtualhost (sub-domain), installed Apache mods where needed and modified the Apache config files.