Tag Archives: PHP

PHP scripting language

Drupal and site performance improvements

Earlier in the year I was part of the team that put live a new site for my employer, moving from a predominately flat HTML site with a little PHP to one using Drupal 7. Here I will go through some of the issues that have been encountered around performance and the steps that I lead to improve site performance over time and as new features have been added.
Please note this is not my site so at times I don’t go into lots of detail around numbers.
Continue reading

Clarity of work focus

It has been over 5 years now since I went and sent up a company so I could work for myself. In that time it has ranged from very lean to actually having to say no to work. There was a short detour back to perm work but in reality their painted picture was better than reality.

Lack of clear direction

One mistake I can readily admit over these years is a lack of clear direction. At times the business has been part:

  1. Full service web company
  2. Hired gun contractor / freelancer inside other organisations
  3. Web site content with income from advertising
  4. Web site services with pay for use

Number 2 has been by far the most successful in a monetary sense with the others suffering from being a small fish in a big wide sea. This is not to say the time spent on them has been wasted. I have learnt a lot about business models, promotion & marketing amongst other non technical skills. But it did have me wearing too many hats, and results suffered because of this.

Current Focus

Over the last 6 months I have consciously been moving to a situation where the company structure is purely to support my freelance software development. No more trying to build the next big thing by myself or compete for small fry work from small companies where the dollar cost seems more important than the benefit that can be derived from their web presence.
The core skills are still developing in a Linux / Apache / MySQL / PHP environment. Working with customising WordPress as a CMS has become much more prevalent, and I have been putting effort into taking my front end web skills around javascript and jQuery to another level. I still like to use my skills working with relational databases.

For the Future

A few ideas for the future.

  • Finding & working with other skilled professionals on a project by project basis. Whether they be a project manager, graphic designer, marketer or other developers.
  • Writing more here and sharing some of what I have leant from a technical perspective.
  • Releasing more code when I am in a legal position to do so under a free license. I have lots of custom WordPress plugins and modifications to other plugins that others should find useful.
  • Understand more about non relational databases
  • Learn and do more development for mobile platforms

Using MySQL stored procedures

A lot of my past software development background has been around client/server in financial markets, with the main RDBMS use in Sybase, but also MS SQL Server and Oracle. In most cases stored procedures is the way to query and manipulate the database. There are a number of reasons for this including security, performance and centralised business logic out of the client.
Now in recent years I have made the move to web development in PHP, and in most cases using MySQL as the database server. From personal experience of others code, and available FOSS systems, it is extremely rare to see use of MySQL stored procedures behind web sites. They are there, have been for a number of years, and do work. So why is this so?
The first reason I could understand, was that they are a MySQL 5 feature, and most FOSS apps set their MySQL minimum requirements at version 4.x.
I now understand a 2nd and crucial reason, thanks to a post by Jay Pipes. MySQL stored procedures are not the same as Sybase or MS SQL. The shared compilation performance benefit is not there in MySQL 5.0/1 for non persistent or pooled connections. ie. most smaller to medium web sites. Their usage may actually be to the detriment of performance.
So stored procedures can have a use in MySQL, but mostly in limited use cases.

Nginx and PHP environment directive

With the Apache web server, I set a server wide directive of which environment the server is in, eg. production, test or dev, using the SetEnv directive. In a PHP script I can pick up this value, and set on all debugging in dev, or suppression in production. Having it set 1 place in Apache means I don’t need to hard code the environment in any PHP code, making movement of code between environments cleaner.
Recently I have begun to use Nginx as the web server with PHP fastcgi for a project, and was looking for a similar set up. The answer I have come up with is an additional entry in my fastcgi_params file. The exact name & location of this file may be different for you. Mine is located at /etc/nginx/fastcgi_params.

fastcgi_param  SYS_ENV             dev;

This way in my bootstrap script I can have the following code:

if ($_SERVER['SYS_ENV'] === 'production') {
    date_default_timezone_set('America/Los_Angeles');    
} else { // Test and dev
    error_reporting(E_ALL|E_STRICT);
    date_default_timezone_set('Australia/Sydney');
    ini_set('display_errors','On');
}

There is probably another way to do this with Nginx, and I would be happy to hear it, as I try and improve my Nginx knowledge.

Is an open license enough?

Does having an open license for a software project, have all the advantages negated if the development process is basically closed to the outside world?

Recently I have been trialling a new web based account/billing software. It is not a very mature project, but the features listed and performance so far have me believing that this is potentially a good solution. Also it is written in a language I am comfortable with (PHP), and it has an open license (GNU AGPL). Hence I may be able to contribute.

However, I have now encountered some issues. The project is under the control of a small company, and project communication is limited to a couple of mailing lists. I have tried direct communication, but the response was things are proceeding, and they are very busy.

The latest planned release date has now slipped twice. I understand software development, and this happens, but public communication has been minimal. Also there is no public source control. In most FOSS projects, a browse of commits will give a good indication of the health of the project, but this is not possible.

So we have a closed open source project. Some may raise the option of forking, but this is almost exclusively a bad result in the long run. So I will wait a little longer, and see how it goes?

Note: I have intentionally not named the software in question, as I still have hope for this project, and do not wish to tarnish the reputation unfairly.

5 Free Software PHP Issue Trackers

If you are using version control in your development, your team or self is most likely wanting to use an issue or bug tracker for your development. There are alternatives to a dedicated product like whiteboards, spreadsheets, email folders or a super memory. However for this article we will compare dedicated issue trackers, and to be more specific, 5 PHP based trackers that are released as free and open source software.
All evaluation was done using PHP5.2.6 on Apache 2.2.9, MySQL 5.0.67.
Continue reading