Learning as I go, my first php/mysql custom cms project

Over the past two months, I have been working pretty hard on a freelance project for a package design agency hmsdesign.com. I have just finished up, but the site is not yet live. The client came to me looking for an easier way to update their website, being that the old site was all in flash. Initially I thought to myself that I would approach this with WordPress, being that Im not a strong php/mysql developer and WordPress would give me a lot out of the box. The trick would be customizing it while still keeping it fairly simple and friendly for the client.

After much consideration, I decided to forego using WordPress and build my own CMS custom for the client using LAMP (linux, apache, mysql, php). Up until now, I have never built something with so many moving pieces, multiple tables, pretty url’s, and multi-part forms using straight php. I had used Ruby on Rails and Code Igniter in the past, but never felt like I had gotten a good grasp of what was going on behind the scenes. I do like the setup of frameworks, but you can borrow a lot of the design patterns of frameworks and incorporate them into your own projects. I have quite a few good books on php/mysql – but the book that helped the most was Learning PHP, MySQL, and JavaScript: A Step-By-Step Guide to Creating Dynamic Websites (Animal Guide).

The instructions I had been given from the client were that they wanted to be able to add projects, images and there were 10 sections. They sent over psd files of the design, and also sent over limitations to how many projects per page, images, etc.

Beginning new projects are a lot of fun, I love figuring out the database setup. I like the sketch out all the fields that I will need, add them into tables, set the foreign keys, etc. Although my database has slightly changed over the 60 hrs of development – its very good to jot something down to base it off. The next step I took was setting up a local development environment on my Mac, I chose to use MAMP. It really helped in having a local database, so that I could really mess around with the database to get it right.

When I had my data squared away, I began on the backend interface for adding new sections. I started off with a very simple form to add a section. I then created a form to add a project, which had a drop-down select with the section name. The project would get added to the database table with the section_id of the section they select, this is essentially a foreign key. I then did the same for images, with a foreign key being the project_id. I had project info stored in the projects table, which I later decided to break out into its own table, descriptions. There was a lot of trial and error involved, but since I was working locally, it wasnt a big deal. When I got stuck I would consult my book, if I got really stuck I would ask my friend, and also sometimes post questions/search stackoverflow.com, my favorite online resource.

After I had a nice backend interface working, I worked out the front-end. Then I showed the client the first round, after discussing how things work, I realized I would have to make the Admin more user friendly. I decided to try to add a way to upload files and save filenames to the database. I had already hit quite a few roadblocks specifically around forms that add/get data from multiple tables, but this seemed like a bigger fish to fry. I spent a snowy afternoon reading through a few online tutorials and within about 4 hours I had my first working cms with upload image capabilities! What a feeling, I could finally look at something like WordPress and really appreciate all the workings behind it.

Needless to say, the client is very happy. I had never promised or even mentioned that they would be able to upload images via an admin interface. I havent shown them v1.1 of the cms yet, but Im sure they will be happy. I could probably spend another 60 hours working on this cms to make it better, I really enjoyed the project and am looking forward to my next challenge. I will try to post a tutorial on setting up a mysql/php image upload demo site in the next few weeks.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: