I started programming computers when I was about 10 years old. My dad had an old 286 computer with an 8 color screen that he’d let me play around with. He brought home a BASIC programming book from work one day and showed me how to start programming. I was hooked. From there I learned Delphi (basically visual Pascal) while I worked in the QA department for Medisoft (my dad’s software company) during high school. In high school I learned C++ and built a killer Asteroids game as my final project. In college I took some Java classes (then decided I didn’t want to surround myself with nerds for 4 years and switched my major to Real Estate. Ha ha…)
Very quickly after working at Infusionsoft, I started to learn web programming – you know, the litany of acronyms (HTML, PHP, CSS…). That’s when I really got hooked on this programming thing. I started learning all kinds of really cool ways to integrate websites and apps with Infusionsoft using these things called a APIs (yet another acronym). To this point though, I hadn’t ever really built anything I’d call an app. Most of the stuff I built (minus the Asteroids game) was simply procedural type programming. I wasn’t using objects or classes or making my own functions or anything like that – it was all single file script type stuff.
That’s actually how I taught myself PHP – by building 1 php script per page of an app called the Email Series Wizard (some of you long time Infusionites might remember that). It took me about a month to build and test it to a point that I was comfortable with people actually using it. It worked really well. Last I looked there were over 10,000 email series campaigns created using it. Looking back though – the code I wrote for that is absolute crap. It’s garbage – like held together with twigs and duct tape garbage. It’s amazing it worked as well as it did. While I was building it, a couple of my friends were building out something else for our Marketing team using this thing called CakePHP. They tried explaining it to me and it seemed too advanced for me (at the time). I was just learning how to connect to a MySQL database to read and write records. I didn’t want to try and learn a whole new programming concept – it seemed like waaay too much. Boy was I wrong.
About a year and a couple hundred PHP scripts later, I decided to go back and learn this CakePHP thing. A few friends told me how much easier it was to build apps using it – once I wrapped my head around how it worked. We needed (read I wanted to) build a real integration with GoToWebinar and Infusionsoft (there weren’t any at the time – and mine is still better than all the others 🙂 ) for the Mastermind Webinars that I was doing. So, I decided to figure out what this CakePHP thing was all about.
If you’re not familiar with it, CakePHP is a MVC framework for PHP (yeah I know – another acronym). There are a ton of these MVC frameworks out there, but their primary function is to make it super simple to build out a web app by having all of the standard functions already built and for you to use – so the developer doesn’t have to reinvent the wheel every time.
MVC stands for Model – View – Controller. An MVC framework separates out the major components of an application into these 3 different parts. The Model is the description of the different components. The Views control how each of the functions get displayed to the users. The Controller does all of the actions associated with the Model.
I often find its easier to understand something by using an example. Let’s say you’re building a web app to balance a check book. The first thing you would need to do is define the data you need to collect. In this case that would be an entry in the ledger.
The Model defines the data points you want to store. In the case of a ledger entry, that would be things like the Date, the Description, the Amount and the Category. The model also describes each of the data points with things like data type, allowed values, whether or not it is a required field etc. So the Date field would be an actual date field in the data base, the Description field would be required and have a maximum length, the Category field would have a set list they could select from, and so on.
Yeah, I know I’m going out of order, but it makes more sense when you explain it this way.
The Controller is in charge of all of the actions you would take for the model. The basic functions are create, read, update and delete (CRUD – one more acronym). The Controller would also have functions to do things like calculate the balance, or total the ledger entries by category. The controller doesn’t display anything to the user, it simply does the work and passes the data on to the view to be displayed. The framework has built in functions that do all the heavy lifting of interacting with the database. It handles all of the reading, writing and security stuff for you. You just have to call the function to save the data. It’s really awesome.
Once the Controller has done it’s job, it passes the data to the View for the display. Views are typically HTML/CSS files wrapped around some PHP to display the data passed from the Controller. That’s it. The View’s job is to get the information and make it look pretty. Built into CakePHP there are a ton of things called Helpers that make it easier to build out different HTML elements like forms, links, ajax calls etc.
Once I got my head wrapped around that concept (and completely different way of programming) and I started writing my first real app, I realized how dumb I was to not try and learn CakePHP earlier. Not only would I have finished the Email Series Wizard in half the time, it would have been infinitely more scalable, secure and stable. I can stand up an instance of CakePHP and have a working app in less than a day (I actually did it in 6 hours last week for a secret project I’m working on). I the past year or two I’ve built an Infusionsoft-GoToWebinar integration, a sorting and recommendation tool for our Consultants to use when helping customers, and an Aweber to Infusionsoft data import tool – all using CakePHP.
The one that I’m most proud of though was Project Sparky. Sparky is/was a tool we used to gather anonymous usage data from all of the free campaigns in the Infusionsoft Marketplace. We recently shut it down and no longer use it anymore, but we used it to successfully record and report on almost 7 million unique events over the course of about a year. I had never built anything that came close to the number of rows in one table like that – and CakePHP handled it like a champ. It took all of about 2 weeks to build it out – all thanks to CakePHP.
So, if you’re comfortable with doing some simple PHP scripts and looking for the next best thing – give CakePHP a try. I highly recommend it.