Mobi Site Launched for SA Dealers

Just finished a mobi version of SA Dealers, has limited functionality but all dealers are listed there.

Was done in Seagull v1.0, and has much of the functionality removed as its not needed on a simple site such as that.

Check it out at mobi.sadealers.co.za and let me know what you think!

Posted under SA Dealers Updates, Seagull PHP Framework

This post was written by Shaun on May 29, 2010

Tags: , ,

Adding far future dates dynamically to any output in Seagull

I have been trying to optimise www.picturearchive.co.za as the database is growing substantially daily, and I want it to have as little impact on the server as possible for future when the database is even bigger.

Using the YSlow firefox addon I noticed that they recommended adding expires headers to the page and the pages elements, this makes the elements cacheable and makes the page appear faster the next time the user visits it.

So after numerous attempts at adding expires headers in to Seagull I sent asked for help on the mailing list. The reply was that there is built in functionality so that you can add php headers on the fly, very nearly anywhere in Seagull!

So I know that the usenet postings are saved to database and never changed after that, so I can add expires headers that are far into the future, so if a user visits the same page 3,4,5 days in a row, he will always pull his locally cached page, saving them time, and having less of an impact on the server.

Below is the code that I implemented in the method that prepares the data to display the usenet article.

PHP:
  1. $expires = 60*60*24*14;
  2. $output->addHeader("Pragma: public");
  3. $output->addHeader("Cache-Control: maxage=".$expires);
  4. $output->addHeader('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');

On the first line we get the number of seconds in 2 weeks (60 seconds X 60 minutes X 24 hours in day X 14 days)

then set the headers accordingly.

I used the Live HTTP headers add on in firefox to see exactly what the headers were that were being sent from the server, that way I could see my changes take affect, brilliant!

I got the headers and the calculation from a users comments on http://php.net/manual/en/function.header.php

I did something similar for the pages that list the thumbnails for the usenet groups, but changed it to cache for a day only, as these pages will change, quite likely daily.

And there you go! 4 lines shoved into you manager in Seagull and you are forcing the browser to cache your pages.

I think that's a job well done, let the framework do the legwork and the developer concentrate on development!

Posted under Seagull PHP Framework

This post was written by Shaun on March 18, 2010

Tags: , , , , ,

PHP Frameworks

mmmmm... So just written (and probably failed) an exam on systems analysis and development where brief mention was given to design patterns.

And a few months (almost a year) back I started working in a PHP framework that makes extensive use of design patterns, called Seagull. It opened my eyes to the possibilities of true Object Oriented Programming and helped me understand how design patterns can be effectively implemented.

One of my first attempts at a personal website using Seagull is a picture archive (www.picturearchive.co.za), here I used Seagull as a base to fast track a website where I could import images and display them in a chronological order, just don't concentrate on the looks, styling is NOT my strong point!!

Seeing how quick and easy that made things, I moved my 'events' website into Seagull as well Seagull has an events/calendar module that I merely 'tweaked'), all I really had to do was write the SQL scripts to pull the info in from the old calendar software I was running, easy peasy!

I have another exam coming up soon, but will hopefully try and dispense of some of the little pearls of wisdom that I have stumbled upon as I felt my way around a well written and stable framework.

I am also hoping to compare it with what I developed from scratch (A long time ago!) and show how the OOP way of doing things makes any module in Seagull much more extensible than my attempt at a framework.

Lastly I want to try and explain design patterns in as simple a manner as I can, hopefully by putting my thoughts out in writing I will gain a better understanding of how if all works, and can implement it more professionally, becoming a better developer in the process!!

Posted under PHP Web Development