Tutorials Category

Google Analytics API class for PHP

Friday, May 29th, 2009

GA marblesAbout a month back, Google opened the Google Analytics API service to all Analytics users. the API allows developers to integrate the GA reports into their own applications or websites, or even access the reports from a phone!

I’ve been thinking about how I can make use of this API to enhance the sites I’m working on. But before kicking off ideas, I had to find out how to access and use the API. I finally came up with a PHP class that will do all the grunt work of calling the API, you just need to supply your report’s parameter and the PHP class will return you an array of Analytics data.

(more…)

Codeigniter: Mixing segment-based URL with querystrings

Monday, March 9th, 2009

Codeigniter, by default crafts it’s URL in a search engine friendly format. It uses a segment-based approach and does away with the all familiar querystring format that developers have been using for many years to pass parameters via the URL into their applications.

Codeigniter does allow you to turn on the querystring capability, but that would mean you have to use a pure querystring approach, foregoing the segment-based approached.

So, is it possible to mix segments and querystring?
(more…)

Codeigniter: Helpers, Plugins and Libraries

Wednesday, December 3rd, 2008

Codeigniter JigsawHaving used Codeigniter for a few months now, this framework is really turning out to be a joy. My last post, I talked about how to modify native CI Libraries.

With so many published PHP classes and functions, it would be a shame if we couldn’t use them in CI. Fortunately CI (like all good frameworks) provides not one but three ways to integrate 3rd code, by using Helpers, Plugins and Libraries.

(more…)

Cacti: Using Cacti to monitor web page loading - Part 3

Friday, September 19th, 2008

Welcome to Part 3 on using Cacti for monitoring of web page loading time. In the previous 2 parts, I walked you through how to install a custom script which will query for the loading time of a web page (Part 1), and how to configure Cacti to start collecting data (Part 2).

In this, and final part, I will cover how to start graphing your data collected within Cacti.

(more…)

Cacti: Using Cacti to monitor web page loading - Part 2

Friday, September 19th, 2008

In Part 1, I discussed about how to use Cacti, a great open-source monitoring tool, for the purpose of monitoring your webpages. More specifically, the time it takes for a webserver to receive the request to the point where the last byte is sent out. I walked through the custom scripts needed by Cacti and how to test that the scripts are working.

In this post, I’m going to cover how to configure Cacti to use the custom scripts I posted in Part 1 and start collecting data for your webpages. In Part 3, I will touch on how to start graphing with the data collected.

So without further delay, let’s get started!

(more…)

Cacti: Using Cacti to monitor web page loading - Part 1

Wednesday, September 17th, 2008

In my current project, I’ve been looking into website performance and measuring how long it takes for webpages to be composed. Although there are plenty of tools both commercial and non-commercial which is available to do just that, they either cost too much or is a one-time data capture tool (which would be quite laborious if we have to constantly trigger it every 5 mins manually).

Instead I investigated on Cacti to see if this commonly used tool by Network/System Admin folks for monitoring network devices and systems can be reworked to let me monitor webpage loading time.

And it did wonderfully…
(more…)

Cacti: Ubuntu 8.04 Cacti Plugin - Invalid PHP_SELF Path problem

Thursday, August 14th, 2008

Cacti Ubuntu problemLately, I’ve been spending a lot of time with Cacti on my Ubunto 8 install. Cacti as we all know is a (great) PHP wrapper application around the rrdtool command. Cacti and rrdtool are typically used by network/systems administrators for graphing network conditions, churning out great looking graphs for various SNMP data.

I’ve been investigating whether I could use Cacti to graph other kinds of data like my website loading time etc. And, it does, brilliantly, but that’s another story for another day.

In any case, after getting Cacti running smoothly on Ubuntu, I decided to try the Cacti Plugin Architecture to see if I could learn how to build some plugins for Cacti. And it wasn’t so straightforward.
(more…)

PHP Class for Date Time calculations - Part 2

Monday, July 21st, 2008

In my previous posting I touched on a PHP class called DateClass (by Steve Powell) that I downloaded from phpclasses.org. The DateClass package actually contained 2 separate classes. One for manipulating dates and the other for date spans.

This post will cover how to use the DateSpanClass to easily calculate the difference between 2 dates, in intervals from seconds to years. Sadly, however, the class have some bugs which needs to be fixed before it can be used.

(more…)

PHP Class for Date Time calculations - Part 1

Monday, July 14th, 2008

Performing data/time calculation is basic requirement in any programming project. No serious application can hide from it, so thankfully PHP itself comes with some very useful data/time functions. But, I feel that those PHP date/time functions are probably great for data/time display and formatting, but not so much for calculating for things like the beginning/end of the week, the number of seconds between two dates etc.

Again thankfully, after a visit to phpclasses.org, I found a nifty little class written by Steve Powell (way back in 2004) called DateClass which did what I wanted. Unfortunately, the documentation was only a class reference sheet, and doesn’t come with any examples to quickly get things going.

(more…)

A look at the Google Graph class

Tuesday, June 3rd, 2008

In my previous post about creating simple graphs using Google Charts API, I mentioned about a PHP class, called Google Graph, which Ryon Sherman wrote that encapsulates this API, making it easier to code in PHP.

I incorporated this class in my CakePHP project, and found that there were a couple of problems with it.

(more…)

Google