Reviewing a CMS solution developed on Mediatemple with the Seagull PHP Framework, including Paypal integration

Wednesday, July 25th, 2007

On Friday 20th July I finally deployed a site which we as a team have been working on for a number of months. Working on the project has been a huge learning curve and has taken way longer than ever expected.

BD4D

The site which I am talking about is http://bd4d.com, which stands for By Designers 4 Designers is built using the seagull php framework with the new cms module

General comments

Media Temple Installation

During the live installation I encountered a few problems, most of which related to permissions of files on the server:

The main one however were the permissions of the /var/lib/php/session/ folder – it has to be writable

Plugins that I found really useful during development

There were two firefox plug-ins that I found very useful during development of the site:

Colorzilla – gives you # codes for colours on any webpage
IE tab – allows you to open up ie7 tabs within firefox, which is great for cross browser compliant xhtml/css

Thanks to the developers of these two add-ons ;)

Paypal

The site has a payment gateway for listing jobs and events which has transaction processing done by Paypal.

In terms of project mistakes, this was one of the biggest we made. The support that James received from Paypal was extremely poor and the general documentation which they supply is often out of date and incorrect. I am amazed that they have become such a successful company, when it is so difficult to integrate their transaction processing into one’s site.

However after a lot of waiting for accounts to go live, numerous queries, emails, phone calls and a lot of frustration, we did eventually get the transactions working. It is working fine now, but it was definitely not worth all of that hassle.

I would be interested to here about other experiences from developers using Paypal – hopefully you had a better one than we did.

Site Features

Showcase

The section of the site that I am most proud of is the Showcase section, which has flash and movies of some really cool clips which the bd4d guys have done. The section allows comments to be made on each of the movies and I think it looks pretty slick – even if I say so myself ;)
To get the section functioning, I used the following:

A comment manager which Dmitri initially developed and then I adapted that code to be used for the site.

To prevent spam on the site I used captcha package from the php pear library

And I used the following code in the template to hold the movies/flash files:

< object width="550" height="400" >
< param name="movie" value="{webRoot}/themes/bd4d/showcasemovies/
{oItem.media}" >
< param name="quality" value="high" >
< embed src="{webRoot}/themes/bd4d/showcasemovies/
{oItem.media}" quality="high" width="{oItem.width}" height="{oItem.height}" autostart="true">< / embed >
< / object >

Events

The Events calendar uses the default seagull events module as a basis, but there where a few enhancements made to fit the requirements of the site. The majority of the development of this section was done by James and I think that he did a pretty good job of it.

The calendar looks pretty slick and works really well, also the backend of the seagull events module provides a lot of flexibility for administrators wanting to manage events.

Job board

The Job board uses custom managers in the default module and as I have mentioned in my section about paypal, it allows members of the site to post jobs for a fee. The transaction processing handles straight paypal payments as well as credit card payments which are verified by paypal.

Conclusion

As I mentioned in the introduction this site took way longer than expected and there were a number of hard lessons which the whole team learnt. But at the end of the day, the site looks pretty good and works as expected, so in some way it can be seen as a success.

Developing a CMS solution on Mediatemple with the Seagull PHP Framework, including Google Maps

Friday, April 20th, 2007

Having just completed the Atalink site, I would like to highlight some of my experiences, frustrations and lessons which I have learnt over the past few months.

Background

I developed the site using the Seagull php framework, using the publisher module (which has recently been superseded by the CMS module).

The publisher module requires a bit of hacking to make it run effectively, especially if the site requires content pages which have different layouts. But, overall the site works well and looks pretty good, even if I say so myself ;).

I have still had a number of difficulties, so for those of you who are planning on building a similar site, here are some of the things which I have learnt:

This is especially relevant if you are going to be using some of the following:

Lessons learned

Tips for using the Seagull publisher module:

If you have various site sections which need to have different layouts, the best way of handling this is to create different content types for each different layout which is required.

Then create a different publisher template for that content type and specify the styling which you want for that particular section.

If you have any exceptions, then use a handler like this:

{if:isEqual(29,articleID)}

{end:}
{if:isEqual(30,articleID)}

{end:}
{if:isEqual(34,articleID)}

{end:}

I will endeavour to write a more in depth tutorial for this and put it on the Seagull wiki. Once I have done so, I will update this post.

Server Issues

The first issue which I encountered was trying to do an installation on a staging sub-domain on a Media Temple Dedicated Virtual Server, where php safe mode was turned on. I have written a post which is a guide on how to successfully remove these restrictions.

Browser Issues

As always, I encountered problems with cross browser compatibility. I discovered huge differences between IE6, IE7 and Firefox. The site looks best in Firefox, Safari and in IE6, but there are a few small differences on IE7.

I used this basic conditional block to include an IE hacks file for when a user views the site using IE.

< !--[if IE] >< style type="text/css" >@import “http://www.atalink.com/ themes/atalink/css/hacks/ie.css”;< /style >< ![endif]-- > (Remove spaces)

Google Maps

Although this is not that difficult to implement, I found quite a useful site called:

Google Maps latitude, longitude Popup , which gives you the latitudes and longitude values for a specific location, which you use in the Google supplied javascript

Design

Although a designer may do a really good job and a client signs off a design, one has to be flexible enough to deal with client requests for changing of the layouts. Often the changes requested are quite valid and one should consider each request before just disagreeing.

Content

Again, I have been reminded about how important it is to have content ready and signed off, before beginning with development. It is amazing how much time can be wasted when you are waiting for pieces of content. Details about content should be agreed upon during initial agreements and no matter how difficult it may be, these agreements should be adhered to.

Conclusion

I have enjoyed working on this site and I have learnt a lot, in terms of development and in terms of communicating with clients.

How to turn off PHP safe mode and remove open_basedir restrictions to install the Seagull PHP framework on a Media Temple sub domain

Tuesday, April 3rd, 2007

Problem

I wanted to run an installation script on a sub-domain of a Dedicated-Virtual server hosted by Media Temple with a Plesk 7.5.4, but received the following php error message when I ran the script:

Warning: file_exists(): open_basedir restriction in effect.

Reason why the error occurs

The reason for this error is because, php safe mode is turned on and because the open_basedir is set for each sub-domain. After quite a lot of searching on the web, I eventually tried a few tutorials, but none of them were comprehensive enough to describe exactly how to solve the actual problem.

Solution

Follow these steps and you should solve the problem:

  1. SSH into your server using the root login information
  2. Once you have logged in, edit the php.ini file located /etc/ folder with a text editor. The line you are looking for is:
    a. Change this line safe_mode = on to safe_mode = off
    b. Or you can cut and paste this one-liner:
    perl -p -i -e ’s/^safe_mode\s*=\s*on/safe_mode = off/i;’ /etc/php.ini
  3. Make sure that the open_basedir in the php.ini file looks like this:

    ; open_basedir, if set, limits all file operations to the defined
    directory
    ; and below. This directive makes most sense if used in a per-
    directory
    ; or per-virtualhost web server configuration file. This directive is
    ; *NOT* affected by whether Safe Mode is turned On or Off.
    open_basedir = none

  4. Then you need to edit the virtual hosts for the domain and for each sub-domain in the http.inc file, which is located in the /var/www/vhosts/$domain/conf folder.
    Add the following section of code to the domain Virtual Host, as well as to each sub-domain Virtual Host


    < IfModule sapi_apache2.c >
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    < /IfModule >

    < IfModule mod_php5.c >
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    < /IfModule >

  5. To complete the process, one needs to type the following two commands:
  6. a. /etc/init.d/httpd stop
    b. /etc/init.d/httpd start

    Hit “Enter� after each command and you should be given an [ OK ] status in the command line.

    Conclusion

    This should solve your problem and if you have any comments, suggestions or improvements, please submit them.

Acceptance testing PHP using selenium

Friday, January 26th, 2007

As we are approaching the final stages of one of out projects, I have been doing some serious acceptance testing to make sure that the site is functioning correctly. To set the testing up, I was given a steer in the right direction and used the Seagull wiki as a guide for the installation….hat tip to Demian.

It is really easy to set the test suite up and to get going, all you really need are the following two downloads:

  1. Selenium core test suite
  2. To record tests the Selenium IDE in Firefox

Once you have installed the Selenium core web application and the plug-in for Firefox (Firefox rocks!!) you good to go:

  1. Plan the various tests which you would like to run
  2. Set the Firefox IDE to record your actions
  3. Once you’ve completed a certain test save the test in an .html file
  4. Include a link to your test file in your main index.html (TestSuite) file, which acts as a table of contents for the various tests
  5. Then you can either run the tests individually or as a batch

If you would like a more detailed tutorial, I found the one on the thinkPHP blog to be quite useful.

As Demian says, you start getting “addicted” to creating tests and eventually try to become a perfectionist - which is a good place to be in if you want to produce error free sites for clients.

Getting to grips with PEAR Quickform and Smarty

Thursday, October 26th, 2006

Over the past few months, we have done a number of projects using the php Smarty package. Smarty is a fantastic templating engine which is quite easy to use and is extremely powerful. It also enforces the distinction between presentation logic and application logic and provides a great deal of flexibility when developing.

On our most recent project we decided to try and use the php PEAR Quickform module. This has also proved to be a easy to use, yet powerful form generator and processor.One thing which I think needs improving is that when forms are generated, the HTML templates are table based. I am sure that the developers of this package are trying to implement this feature on later realeases, but the package we are using doesn’t generate semantically correct HTML forms.

However, to overcome this sticking point, we combined the smarty and quickform packages to produce semantically correct HTML templates, which have validation and processing ability.

The form generation, validation form processing are extremely quick and provide an awesome amount of felxibility when it comes to both presentation and application logic.

It is truly awesome what can be acheived using open source code.
Go php!!! ;)
For those of you who are intrested in learning about quickform and smarty-check these links out: