November 2, 2006

PHP - Where exactly do you sit?

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 11:43 pm

I read an article recently about more on the Zend and IBM partnership, which I have been aware of for some time, but hadn’t quite seen it phrased this way - PHP is to compete against .NET for SME web applications. For me that was a big ‘wow’ statement.

When researching technologies for enterprise application development I have seen often a lot of Java technologies such as JSF, Spring/Hibernate, Struts and Tapestry - yet I rarely see in the same article the emerging structures from PHP or .NET. It is like there is a bottom teir that  PHP, .NET and RoR falls into, great for lower level projects or specific implementations (such as rapid development with RoR and .NET, and speed and simplicity of PHP) . It has made me really think about how PHP lacks against the other technologies, and also trying to identify the best use for PHP - where does it end and others begin? If at all?
For me PHP has clearly been always a light-weight development tool that performs well. But it does lack a lot of enterprise level functionality, such as persistence layers and MVC frameworks and a useful class API (not just functions, but well structured classes/interfaces). This has sparked a lot of additional projects such as PEAR/Pecl which has aimed at providing additional class functionality. As a comparison I have seen .NET to have those parts of the application framework solved as part of its standard offer, and C# is great, but if you were to step up to that level you would be better off stepping into the JEE realm, as there is much more richness, developer focus, resources and technologies (personal preference) - and “it isn’t evil” as my old boss would say.

As a result taking the leap from PHP to JEE has been in the past quite large, and there is often debate in my mind where the line is between the projects. If you step up from PHP not only do you need a dedicated production environment (no adequate shared hosting in Australia) but you need to step the whole infrastructure of your applications up in their configuration. This has lead me down the path of introducing and leveraging off contributed frameworks for PHP, which have almost always been modeled off Java. Persistence layering homegrown, database abstraction ADOdb, MVC with php.MVC etc.

But once you start to build your aps and really press into these different packages you start to feel that you are just trying to implement concepts that have been around for 5+years in Java anyway, and hunders of developers are contributing to its stable releases and documentation. Also you then start to encounter overheads in loading of packages of PHP and then find you have to use cut down versions (such as ADOdb_lite etc) to try and pick up the performance back for your requests (as every request builds up and tears down). It feels like you are always trying to port framework ideas into PHP, when if you just took the next step up to JEE all your problems will be gone. But remember, dedicated production environment, bogus configurations, argh!

So I am interested to see what Zend and IBM start to introduce to make working for small to medium enterprise applications easier, without ending up creating a mix and match purpose driven dribble snippets of code, like a API to work with google, instead of dealing with creating a real set of structure that you can build off. Real sets of interfaces and classes to deal with first, then the nicer tricks built off the top.

So what things do I dig at the moment that are going on in the PHP world that will really excite where it is going?

- PDO - Formalising some structure behind database connectivity
- SDO - Single API for data, introducing concepts of Persistence and Object Relational Mapping
- XML - PHP5 with various additions of DOM, simpleXML etc - XML is great for almost everything
- Web Services - Ensuring future interoperability with larger parts of the application
Hopefully with the Zend Framework being developed on we will see more core structure and packages coming out dealing with collections, HTTP request objects and database etc, and then eventually see more application frameworks (MVC’s etc) being introduced. This may lead to a scenario where PHP can really sit into that small-medium project size, being able to be as simple as a Hello World web application in 1 line but still having the ability to scale into a medium app with MVC, abstraction and persistence. And, due to the XML and Webservices functionality provided in the newer PHP versions we will see PHP sit more and more definatively into its position in the industry.

Today’s funnies

You will find other articles relevant to this document in these sections:
Richard Lee @ 3:41 pm

An interesting game simulating a real life web browsing scenario (brought to you by beta.com)
http://www2.b3ta.com/realistic-internet-simulator/

Internet Explorer Kiosk Mode

You will find other articles relevant to this document in these sections:
Richard Lee @ 3:10 pm

I was skimming one of my Google Groups today and I came across a user asking how to launch a page in fullscreen for his kiosk application. Lots of contributors were talking about creating links to launch chromeless windows, fair enough for a website but not a kiosk application :) Internet Explorer 6 actually has an inbuilt kiosk mode. Just pass -k to the command line and IE opens fullscreen booya!.

Typically this is done through a shortcut:

1. Right-Click Desktop

2. New Shortcut

3. Enter this as the location:

“C:Program FilesInternet Exploreriexplore.exe” -k

4. Enter a name:

“Launch Kiosk”

5. Finish

Just remember to Alt-F4 to close the window ;)

Some CSS Tricks

You will find other articles relevant to this document in these sections:
Richard Lee @ 11:00 am

1. Centering a block item horizontally

To centre a fixed width div we can use the CSS margin-left and margin-right commands set to auto. For pre IE 6 browsers you’ll need to use the text-align property set to centre:

body {
 
text-align: center;
 
}
 
div#wrapper {
 
margin: 0 auto;
text-align:left;
 
}

2. Centering content vertically

Having troubles getting vertical-align to centre? Forget it. Set the line-height to the same height as the container like so:

div#cell{
 
height: 24px;
 
line-height: 24px;
 
}

3. Using images for stylish headings

Using images for stylized headings is okay, but we should make sure the heading is still accessible to a screenreader. To do this we can use a background image on the header tag and hide the plain text from view using the text-indent command:

div#banner h1 {
 
height: 26px;
 
text-indent: -2000px;
 
background-image:url(images/header1.gif);
}

4. Getting backgrounds to stretch the full length of a container

CSS has issues controlling things vertically - take backgrounds and vertical alignments for example. If you need a background colour to extend the full length of a block element such as a div you’ll need to use a background-image and tile it vertically:

div#content {
 
background:#fff url(images/bg.gif) top left repeat-y;
}

5.Using 2 classes together

In CSS you can apply two classes to an element. For example, in my piped horizontal lists (Eg Home | About | Contact) I have a selected class to highlight the active item and a last class to remove the piped character from the last list item. To apply these two classes I simply add both classnames to the class attribute seperate by a space:

<a class="last selected" href="home.html">Home</a>
« Previous Page