Blogs

Writing a simple OO template system in PHP to separate logic and presentation

If you're maintaining a legacy PHP application which suffers from mixing of application logic and presentation, you may want to implement a simple template system to help separate these two.

Of course there are plenty of existing PHP templating systems, with Smarty being one of the most 'notorious' ;-). But if you have simple needs and don't want to introduce external dependencies to your code, rolling your own simple system can make sense. Let's face it -- you can often roll your own in the time it takes to figure out someone else's system.

Categories: 

Simple Progress (Load) Bar with jQuery

Let's say you need to load some info into a page, but the info requires some time to process. You don't want to have the user staring at a blank screen during the processing, so first load the page with a busy (progress) bar image and then replace the image with the actual data when ready.

Assume you have this HTML page :


<html>
<head>
  <script type="text/javascript" src="/js/jquery.js"></script>
  <script type="text/javascript">
    $(document).ready(function() {
        $('#one').load('/one.php');
Categories: 

Cheap PHP lint checking with Git

Running PHP's "built-in" lint checker (php -l) is a quick way to remove syntax errors which should never creep into your code.

However, you'll no doubt soon tire of typing "php -l" before every Git commit message, so why not let Git do the checking for you with a "pre-commit hook".

Travis Swicegood has a great article on how to set this up with Git :
http://phpadvent.org/2008/dont-commit-that-error-by-travis-swicegood

I found you could pretty much copy his pre-commit PHP script and paste it into your .git/hooks directory with a couple caveats :

    Categories: 

    Running Selenium PHPUnit tests against Firefox in an Ubuntu virtual machine

    As part of my Hudson CI server, I'm trying to run Selenium-based PHPUnit tests with each build. The build machine is an virtual machine (VirtualBox) running Ubuntu desktop.

    Initially, my tests weren't running thru Hudson and the associated build.xml file. This wasn't surprising since I had forgotten to start the Selenium RC server.

    Useful Drupal "Third-party integration" Modules

    Using the Hudson Continuous Integration (CI) tool

    I recently started writing some automated Selenium (Se) tests . I wrote a few tests, and Se seems to work well. But after writing a few tests, I found I needed an easy way to run, report, and track test results.

    This lead me to Hudson, a Continuous Integration (CI) tool.

    Hudson builds a given project and then does a number of useful things :

    • Automatically run unit tests and provide coverage reports
    • Show style, syntax, and complexity results

    Setting up Custom Coding Standards with PHP CodeSniffer

    PHP CodeSniffer provides you with some useful coding standards to get you going.

    This is nice, but how do you customize what's provided or set up your own standards?

    There is a tutorial on how to set up your own standards, but that was too much work for me at the moment.

    However, that is NOT the way to set up your own standards, in my opinion.

    Categories: 

    Adding PHP CodeSniffer to your Hudson Phing Continuous Integration Process

    In a previous post, I described how to setup Hudson with Phing and PHPUnit for a simple PHP build process.

    Adding PHP CodeSniffer to Build Results

    Now let's expand on this a bit by adding PHP CodeSniffer (PHPCS).

    First, assuming you're still working on Ubuntu, install PHPCS :

    $ sudo pear install  PHP_CodeSniffer
    

    Add the Checkstyle to Hudson (Manage Hudson => Manage Plugins => Available).

    Installing Hudson, Phing, PHPUnit and Git on Ubuntu

    In this post, I'm just trying to get the simplest setup. I'll try to post details in a subsequent post.

    Here are three posts, in descending order, on this that I found useful :

    http://toptopic.wordpress.com/2009/02/26/php-and-hudson/

    http://blog.jepamedia.org/2009/10/28/continuous-integration-for-php-with...

    http://www.davegardner.me.uk/blog/2009/11/09/continuous-integration-for-...

    First, I had to install java :

        $ sudo aptitude install sun-java6-jre  

    Pages

    Subscribe to RSS - blogs