Remote libnotify.

I think most Linux users might be used to libnotify by now, you’ve probably seen stuff like this;

libnotify

Appearing when you get an message in Pidgin or when you get a new email if you use cgmail.
Now if you have notify-send installed you can have some fun with this, for Ubuntu users just

apt-get install libnotify-bin

Now let’s test this baby out,

notify-send -i gtk-info "libnotify example" "An example of libnotify notification thingy."

And you should get a notification similar to the image above.
The parameters are fairly simple

notify-send -i

Already I guess you can see the possibilities, you can roll this into a bash script, use the python bindings directly in one of your programs or call the command via any language that supports calling external programs.

For me I don’t really have any programs running on my desktop machine that really needs notification, but I do have several scripts running on my MythTV box. What I’d like to for them to be able to push notifications on to my desktop machine.

Enter ssh. I already have ssh setup on my desktop and MythTV box so that I can ssh in and out without using passwords, so let’s test these out.

andrew@desktop:~ ssh mythtv
andrew@mythtv:~ ssh desktop
andrew@desktop:~ notify-send -i gtk-info 'test' 'test'
libnotify-Message: Unable to get session bus: dbus-launch failed to autolaunch D-Bus session: Autolaunch error: X11 initialization failed.

Hm, well to be expected. Running GUI programs on a remote machine requires a little more work, let’s try again.

andrew@desktop:~ DISPLAY=:0.0 notify-send -i gtk-info 'test' 'test'

If you still have problems at this point, check you are using the right value for DISPLAY variable.

andrew@desktop:~ xdpyinfo | grep 'name of display'
name of display: :0.0

If that looks o.k., then make sure that your X server is setup to allow remote connections from the machine you are going to use.

andrew@desktop:~ xhost +mythtv

or

andrew@desktop:~ xhost +192.168.0.10

And finally, hopefully things are working o.k. now so simply wrap the notify-send command into a ssh call.

andrew@mythtv:~ ssh desktop 'DISPLAY=:0.0 notify-send -i gtk-info "test subject" "test message"

Success!

The next step is to work out a who to push libnotify events to a laptop with a roving IP address.

Upstream/Downstream

Well Ubuntu have started Brainstorming for ways of improving their OS, great stuff.

But browsing through the suggestions brings home the reality. No one cares who’s fault a bug is, they just want it to work.

Generally bugs fall in too three categorises;

  • Problems with hardware
  • Problems with software
  • Problems with packaging and distribution

Problems with hardware
These crop up again and again. For example Fix suspend and hiberante. I’m currently running on a MacBook Pro with a ATI graphics card, and suspend doesn’t work for me. Is this Ubuntu’s fault? Not really, the problems lies somewhere between the kernel and the propitiatory graphics driver. Can Ubuntu do anything about this? Not really.

Problems with software
A classic example. Restore deleted items trash bin, a problem with the way Gnome deals with it’s trash. Gnome know about this problems, but if you want a good example of how they deal with things check out the third comment.

As nice as this is feature would be, it doesn’t seem required.

This exists on the Macintosh, and as John says, “as far as I know, no one uses
it.”

Now while the Ubuntu developers could patch this, it’s quite a big problem to fix (it would require changes to the underlying Gnome file system handler) it would mean having to patch every Gnome update. Unless Gnome are willing to implement this themselves it’s unlikely to make it into the next version of Ubuntu.

Problems with packaging and distribution
For anyone that’s reinstalled Ubuntu on a existing system you’ll know this bug, Auto-detect existing /home partition during installation. Yes as good as Ubuntu is, if you’re moving from one Linux version to another you’ll have to manually fix your home directory. This is the sort of thing that Ubuntu can fix, and I’m surprised they haven’t do so sooner.

Which leaves me asking two questions;

  1. Do people really understand the difference between a distribution and the software?
  2. More importantly, should they?

With the first two types of bugs the problem lies in areas that Ubuntu can’t pro-actively fix, they either have to wait for someone else to fix it or put pressure on them until they do.

For the average user, they don’t care they just want things to work.

So what’s an Ubuntu to do? They have all these suggestions any they realistically can’t change 2/3rds of them. Perhaps new Linux users should be better educated into how the OS works, so they can put pressure where it would really make a different with the hardware/software people who can actually make a difference.

Linux and Gadgets

Well it’s that time of the month again. Pay day as hit, I feel flush and it’s probably going to be another week or so before that unexpected big bill hits and I’d reminded how much money I don’t actually have.

Either way I’ve been poking around various websites drooling over gadgets, and being the Linux person I am checking out how well they support Linux (that’s GNU/Linux if Mr Stallman is reading this).

MP3 Players
I’m reminded of that old Michael Caine misquote, “Zulu’s hundreds, thousands of them”. They come in all shapes and sizes now a days, and Apple have even managed to take a leaf out of Hoover’s book and made the name iPod synonymous with mp3 player, which I personally hate and can see where Richard Stallman gets his Linux<->GNU/Linux rage from.
When it comes to buying an mp3 player the most important thing a Linux users has to consider is how songs are transfered. Currently there are 3 ways

  • MTP, the Microsoft way which requires Windows Media Player
  • iTunes, the Apple way which obvious requires iTunes
  • Mass storage device, the way that will work on any computer as it appears just like an external hard disc

So in order to be able to use a MP3 player in Linux without having to rely on a third party project reverse engineering various protocols I’m looking for a player that supports mass storage as a transfer option. On top of this, this open source advocate in my wants to find a MP3 player that supports OGG as well, even if it’s just for the simple reason all my music is already encoded in OGG.

Laptop
Hardware support in Linux is always improving. And now there are even vendors selling laptops with Linux pre-installed, kudos to those manufacturers that do this, but I have to question why they still don’t allow you to buy any computer/laptop with the option of NO OS. Currently Dell sells their Inspirion 1525 and the XPS M1330 with Ubuntu pre-installed, but the list of Windows laptops is much greater. Why not simply have the option of buying a laptop without a OS installed? Every item from the Dell line is configurable to a certain degree, add/remove ram as you see fit, but not the OS. Strange.

Anyway this is a minor tirade. The point I’m trying to get across is, as a Linux user I’m started to become much more aware of what I buy. Not only because I want to be certain that what I buy works with the OS of my choice, but more importantly I want the company I’m buying from to be aware as well.
I could easily buy an Ipod and use something like libgpod to access it, but what message am I sending to the makers? As far as they know I’m another Windows/Mac users. I want them to know I’m using Linux, that if they decide to update their propriety transfer protocol that I won’t be able to use their supposedly easier to use MP3 player.
Similarly I could also spend an extra £20-£50 and open myself up to the whole range of Dell a laptops, rather than just restricting myself to the two they choose to sell with Ubuntu preinstalled.

What I’m asking, as one Linux user to another, is when buy hardware don’t only think about if the device is works in Linux, but also take a moment and choose a manufacture who supports Linux. If you want more Linux support for your hardware and gadgets you should do this every time you buy.

No

Lily Allen ‘in talks’ to become Doctor Who’s assistant

Just no.

Is Linux ready for the desktop isn’t even the right question.

Linux (GNU Linux for the pedantic) is improving with every release of each distro, and every time a new release comes out people ask yet again “Is Linux ready for the desktop?”

Sometimes the people asking have valid complaints, unsupported/buggy hardware, bugs within the software provided, difficult install methods, etc. A lot of the time the complaints mostly just come down to “Linux isn’t Windows”, where the reviews for some reason expects Linux to be a exact Windows replacement and any where Linux differs from Windows is seen as a fault.

In my opinion the Ubuntu install process is on par with Windows, possibly even better. Hardware support will always be a problem under Linux due to hardware manufactures not providing drivers, most claim that the Linux user base isn’t large enough to cover the development costs. This is the same line that most proprietary software companies use as well, whether it’s Adobe’s Photoshop or Value’s Half-Life.

Now this is where I think the real issue lies. The question shouldn’t be “Is Linux ready for the desktop”, for me and thousands of others it is. I don’t claim Windows isn’t ready for the desktop, but for me it’s not an operating system I could use on a regular basis, it simple doesn’t provide me with the features and functionality I need.
Currently reviewers look at Linux and it doesn’t work they way they expect so they cite this as a reason that Linux isn’t ready for the desktop, so therefore by the same standards I can say with equal validity that Windows isn’t ready for the desktop. Of course neither is really the case.

They real problem with Linux (and in some cases OS X as well) is the inability to run on common hardware and more importantly to run proprietary software that people have and are used to. This really becomes a chicken/egg situation, companies won’t provide software due to lack of users and users won’t use the OS due to lack of software.

So the real question that everyone should be asking

How many GNU Linux users are there?

This is what it really comes down to. For some Linux will never be ready for the desktop until it’s an exact copy of Windows, and these are the people that will never be converted. For most others, Linux isn’t ready because it doesn’t support their hardware or they can’t run various proprietary software. These are the users we should be aiming to convert, but unfortunately we can’t with out solving their basic problems. And this is an area no amount of OSS development will fix, we need to convince the companies that don’t provide drivers or don’t provide Linux version of their applications that Linux is a signification portion of the market. A portion large enough to cover the cost of development.

But in order to do this we need to be able to them with solid figures on the amount of Linux users out there.
This is where one of Linux’s assets becomes it’s greatest failure. Linux is free.
Currently there are several ways that we can try and count the amount of Linux users, but none of them really give accurate information. With Windows and OS X they can give you a nearly accurate figure because they sell their products. Microsoft sell X copies of Vista, so they can say they have ~X Vista users (even though some may reinstall XP or install Linux).

Currently, as Linux is free, there are a number of way you can get Linux but non of the provide a accurate representation of the current user base.

Downloading
I’ve download various verison of Linux 10’s of times in the past year but I’m still only one user. Other download Linux, give it a try and then go back to Window for whatever reason
Buy a CD
Similar to the download situation, people buy Linux CD’s either to give back something to the community or to get support. Either way some of these users may go back to Windows, or not even install the CD they receive.
Given a CD
There are some people that spread the good word by giving away free copies of a Linux CD to to others, again some may install where other may not.

Which ever method you choose to install/try Linux, it’s not something that can be considered an accurate representation of the current Linux user base. It’s about on par with examining browser statistics for web site to find OS distribution, it give no real indication of how many people are really using Linux as their default OS at home.

There are other systems setup, such as the Linux Counter, but these are all opt-in system. I only heard about the Linux counter in the past few months, many other may not of heard of this or heard of this and not signed up. For this reason alone the Linux counter “guess” at the number of Linux users should be considered just that, a guess.

So what’s the solution
To be honest I don’t know, but we need to start an initiative that will provide near enough solid figure on the current amount of Linux users. A cross distribution method of counting the number of people who do see Linux as ready for the desktop.
The beauty of Linux is not only that it’s free but that it’s also anonymous. You don’t need to buy or register your copy of Linux and you can choose if you want to receive updates or support. But maybe this is something that should be reconsidered. While I don’t want to see my favourite Linux distro acquire an open source version of Windows Genuine Advantage, I think the only way we can really start to see the true number of Linux users is for the major Linux distro to start incorporating a opt-out registration process. Perhaps if all Linux distros implemented a registration process, one that people are free to refuse, in their installer software we could start to see some solid numbers regarding the amount of Linux users out there. Even then this may not be enough.

Part of me wouldn’t like to see this come about, but it’s evident that in order to be taken serious as an operating system we need some way of saying Linux has x amount of users/y% of the market. Until this time companies won’t take Linux driver/software as a serious development option.

Shopping list. Beer, Milk, Linux, Pizza.

It never fails to amaze me the things you can get down your local Tescos Supermarket, not only food and house stuff but TVs, garden furniture, clothes, pretty much everything you could want. And now they’re selling computers with Linux pre-installed.

Give the specs of the machine it’s not surprising they’ve gone with Linux over Windows Vista. But if there’s one main feature that’s likely to attract customers, it’s the fact it’s cheap. Only £140, but the lack of a monitor will probably put off some, and the warning sign at the top might confuse others;

PC uses Linux Operating System

The choice of OS on the face of it isn’t surprising, given Ubuntu seems to have captured the interest of first time Linux users it seems a wise move. A nice balance of easy of use and a great community associated with it. But what’s this? Ubuntu 6.06 LTS. :( Now offering a OS with is guaranteed to have 3 years of support is a great idea, but not when the OS is 2 1/2 years old.

While it’s great to see shops starting to provide computers with Linux pre-installed, offering what may be considered out-dated version of an OS isn’t going to help the cause. Can you imagine what people would think of Windows if it came with Windows 98 rather than Vista/XP? Ubuntu has come on leaps and bounds in the last few years, 6.06 is a fine OS but not a good reflections of the current state of the Linux desktop.

A song for the Web 2.0 generation.

Hey I’ve got that font - The Gothsicles

The boss isn’t looking
So I use my screen
For browsing an online music magazine

And there I see a thing
That I can’t believe
There are still band logos made with Ogilvie

’cause me,

I’m something of a typeface connoisseur
I eat chicken wing dings with my font du jour [tofu chicken]
And I can spot your shitty fonts like a cheap toupee
And still blow you away
With my Arial display

And when it comes to fonts,
I annihilate
And when I print my fonts,
I always collate
Some are narrow and condensed,
Others heavyweight
And I’m more gothic
Than any Copperplate

Hey, I’ve Got That Font
And a full directory of all the TrueType you could want
Hey, I’ve Got That Font
They used Alleycat to advertise that local restaurant
Hey, I’ve Got That Font
With bolds and italics from here to Vermont
Hey, I’ve Got That Font
Creepygirl and Rockwell, I’m a fuckin’ font savant

There are so many fonts that I recognize
Zoom in all you want, they won’t pixelize
‘Cause I know the good shit from the replicas
I’ll see you in Helvetica

and then a

Big fucking axe will cut off your hands
You used to be serif, but now you’re sans
And I got plans to make that font
Used by Mickey D’s
I’ll trace it out with the blood
From where your hands used to be

I customized a font so each serif ends in a hook
But your custom font looks like gobbledygook
And that’s not Eras Lite but Eras Medium that you mistook
And I’m more gothic
Than any Franklin Book

Hey, I’ve Got That Font
And a full directory of all the TrueType you could want
Hey, I’ve Got That Font
They used Alleycat to advertise that local restaurant
Hey, I’ve Got That Font
If there was a typeface army, then I’d be the commandant
Hey, I’ve Got That Font
I sell ‘em to pay off my Mitsubishi Galant

Morpheus
Times New Roman
Ultraworld
Bookman Old Style
Garamond
Liquidism
Comic, Bloody, Impact

Verdana
Goudy Stout
Century Gothic, Bauhaus

Joystix
Buffy
Liquidism 2
Metal Lord
Courier New

PHP and CodeIgniter

Again on the trail of a framework that suits my needs I done the fabled felt trimmed fedora and dive into the PHP framework CodeIgniter.

This was a framework I heard of through various forums, promising a rails beating framework in PHP. CodeIgniter promises a lot

  1. You want a framework with a small footprint.
  2. You need exceptional performance.
  3. You need broad compatibility with standard hosting accounts that run a variety of PHP versions and configurations.
  4. You want a framework that requires nearly zero configuration.
  5. You want a framework that does not require you to use the command line.
  6. You want a framework that does not require you to adhere to restrictive coding rules.
  7. You are not interested in large-scale monolithic libraries like PEAR.
  8. You do not want to be forced to learn a templating language (although a template parser is optionally available if you desire one).
  9. You eschew complexity, favoring simple solutions.
  10. You need clear, thorough documentation.

All of these points appealed to me, my only concern was with “does not require you use the command line”. As a long time Linux users I don’t fear the command line, I embrace it for what it allows me to do and how easily it allows me to achieve that. But if CodeIgniter allows me achieve the same functionality without dropping into bash, who am I to complain?

Installation
As promised CodeIgniter doesn’t require any additional libraries, as long as you have PHP setup so that Apache can access it and you can connect to the database flavour you require you’re all set. As for the actual installation of CodeIgniter, there isn’t any the download itself is the bare bones skeleton of a project. Just download the CodeIgniter source to your project directory and start working!

Documenation
Documentation is available via the CodeIngiter website and also comes with the download, which is good. Nice to be able to carry on coding without needing an internet connection. As for the tutorial there are two available and introduction and a blog in 20 minutes. The blog tutorial suggests complete the introduction tutorial first as it assumes some knowledge you’ve learnt from that, so maybe 20 minutes is a more conservative estimate. Also I should point out that of the frameworks I’ve looked so far, CodeIgniter is the only framework that provides it’s tutorials via video only. Maybe not a big deal, or maybe I’m just getting old but I’d kind of prefer to read through the tutorial. While it’s nice to be able to see someone else writing the code and explaining what they do it would also be good if there was a text version that you could refer to and read through at your own speed.

The actual documentation is of good/clear quality. Divides between general topics associated with coding a framework and information on the various class that CodeIgniter provides, so as long as you’re familiar with the current framework buzz works you’ll be able to find the information you need.

Again, CodeIgniter provides all you expect from a framework, even unit testing. But for some reason this is one area I found it lacking, the documentation tells you how to create unit testing, put seems to provide no documentation on who to run these test? But perhaps this is more me being blind than bad documentation, hopefully someone will correct me.

Configuration or convention?
For me this isn’t an either or situation. When I’m starting out with a project I don’t want to spend half my time creating/editing configuration files I just want to get a basic site up and running, but on the other hand once I get going into a project I may want to be able to change things. CodeIgniter puts itself firmly in the convention camp, through naming of files/classes/databases. While it’s possible to not use this in some place in CodeIgniter you’ll find yourself fighting against it. I find myself spending too much time fighting with my current web application language/framework, it’s not something I’d knowingly want or be willing to get into again unless the benefits out weighted these problems.

All this said, CodeIgniter isn’t for me. Perhaps if you are starting out with a fresh site and have a knowledge of databases already CodeIgniter might be worth a look. But when I can use other frameworks to automatically generate the outline of a project what is there for me with CodeIgniter? That said it does provide on nearly all of it’s promises. At 2Mb for a default install it’s a vast improvement over Symfonys which comes in at over 10Mb when you “freeze” the project. The documentation is certainly clear and concise, it doesn’t depend on “monolithic” libraries, there’s no command line, it should work on all PHP hosts you throw it on, with the usual exception of the database there no need for configuration. The only questionable aspect is performance, only because it hard to really test until you throw a project like this up in a production environment. Hmm for me the size of the project really isn’t that much of a problem, especially with hard discs being so cheap nowadays. “Monolithic” libraries are really a personally call, the class/functions the provide work well but for some reason I’d still rather put my fair in a tried and test third-party library. As for the lack of a command line, I see this as neither a good thing or bad thing as long as I can still achieve the same ends, but for me CodeIgniter (even with it’s lack of configuration) didn’t provide.

I have no real complaints about CodeIgniter, it’s just not what I’m looking for. CodeIgniter states on it’s frontpage it’s aims and it fulfils those admirably, unfortunately those aims are not what I’m looking for. CodeIgniter is a well crafted and concise framework, well worth a look it it’s aims meets you’re requirements.

PHP and Symfony

Once again out comes the felt trimmed fedora as I take a look at another PHP framework in my on going review to find a web framework that best suits my needs. Today I’m testing out Symfony.

First off it should be noted that Symfony is a PHP5 only framework. For some this may not be a problem, but for those looking to host their site on the majority of web hosts around this could cause problems. Now I’m lucky in that the servers I’ll be looking to host on will either be run by myself or have PHP5 as an option. Support for PHP4 is set to be discontinued, at the end of this year there will be no more releases, and critical security updates will only be available until August next year. According to some PHP5 only accounts for 22% of the of generally available versions of PHP on web hosts. So if you’re looking for a PHP framework you really should consider you’re hosting options before looking at Symfony PHP. Personally I welcome the change to PHP5, the OO style is much improved over PHP4 and I’m hoping that this will at least give web admins a good excuse to make sure set up sensible configuration options, I mean if you’re going to break compatibility with old scripts you might as well do it in a worth while cause.

Anyway Symfony is another framework that for the most part glues together what it considers the best PHP libraries around for the tasks it needs. Pake and Phing for project build/management, Propel for ORM, Creole for the database abstract and homegrown Lime for unit testing.

Installation
Again installing was easy, Symfony was available via apt/fink (got to love package management tools). Those without one or who prefer to install the latest and greatest Symfony is also available via PEAR. For Perl people this is something akin to CPAN, and those Slytherins amongst us I guess easy_install/setuptools would be the closest analogy. Those installing by hand will want to make sure that they have the required libraries mentioned above installed.

Documentation
The documentation is good, like some other frameworks they are developing a Symfony book, API as well as a general documentation on the framework. Not to mention a snippets library, wiki and forums for you to ask your questions. For some reason, although I found the documentation itself good I find the index a little confusing, it seems to be more of a small keyword index rather a more descriptive index.

As for howto documentation there is the basic blog done in symfony, the more complex askeet in 24 days/hour and a host of community how tos as well. I should note that I was going to look at symfony first, but a month a go when I first looked at the askeet tutorial there seemed to be a problem with the website that prevented me from getting past the first day, but that seems to be fixed now. Going with the “official” how tos I plumbed for the basic blog, but if you fancy something a bit more in depth the askeet is excellent, not only covering Symonfy but also takes you through the basics of working with SVN while developing.

The basic blog tutorial only covers one page, and while the result doesn’t look that great it does give you enough of a run through creating database/models/controllers/views etc. This tutorial expects you to download a pre-created skeleton project, but if like me you create the project from scratch using the symfony command line application then you’ll need to make sure you configure you’re database correctly. For me this just meant editing the propel.ini/database.yml to point to you’re database correctly.

Which brings me on to another point. Symfony configuration is done through a file format called yml, those not familiar with this shouldn’t worry as it’s a very simple format and the documentation covers exactly what these different configuration files expect. The only downside I saw from the configuration was that in order to specify your database you have to edit both database.yml and propel.ini so you’re project knows where the database is and also that command line tools that uses propel knows where you’re database is. This is a minor point as you probably won’t be changing your database that much, but it would be nice if these could be integrated some how.

Another minor point regarding documentation is that propel, the library for automatically generating your database/model can be done via both yml and XML. The basic tutorial takes the yml approach and the askeet tutorial goes down the XML route, not a big problem but I’d like to symfony take a stand on one or the other if at least for consistence in the tutorials, even thou it’s good that it allows both types of configuration formats to be used in production.

Other than that I found the tutorials of excellent quality, the framework seems to allow you to provide the minimal details required to get up and running while allowing you to override these things later on. Controller function is done via named convention, or more correctly a controller function name needs to be prefixed with execute e.g. executeIndex, executeUpdate, etc. Models are provides via a super class convention, when you create models via the command line from your database it create Peer classes which your actual model classes subclass. So if at a later date you need to recreate your models you can do so with no or minimal changes to your actual class files. While models are specific to your project, like Django, Symfony allows you to create multiple apps in each project. Each app can access the same model but you can create different controller/views for these apps.

A little spit and polish

Symfony provides all you expect from a framework, automatic creation of database/models, ORM, unit testing, batch control the works. The automatic creation of models,controllers even scaffolding/admin views allows you to get up an running quickly with minimal configuration, while the configuration possibility coupled with the clever class systems of models allows you to expand this should you need.

I have to say I’m impressed with Symfony it seems to provide it all but I doubt it would be too easier to change the ORM library should you need but those preferring Smarty over PHP for the templating should take a look at the sfSmartyViewPlugin. Now Symfony has hit the big 1.0 the API should be stable and the documentation is top quality generally. My only real complaints are that parts of the documentation could do with a little polishing to round off those confusing corners, but those are minor complaints.

So if you can get past the fact that is a PHP framework (this is hard I know) and you know that you’ll be running it on a web host that supports PHP 5 then Symfony is worth a look.

Addendum
How could I forget two of the most important things that really turned my head while using Symfony?
Firstly the symfony commands “freeze”/”unfreeze”. When developing a project using the command “symfony freeze”, will copy over all the libraries that symfony uses to you project directroy, so when you upload it to your production server you know that it will be using the version of the libraries that you developed it in (unless a conflict crops up of course). Similarly unfreeze will remove those libraries from the project directory so you can test with updated libraries before “freezing” again and re-uploading to your production server!
Secondly, and possibly more importantly for developing, Symfony provides a web debugging interface. O.k. debugging might be the wrong word, take a look at this;
.
Did I mention that when Symfony creates a app for your project it automatically creates a production/development environment for you to work with? No? Sorry, well it does. So when you’re working within the dev environment you’ll get this special toolbar which gives you information about the process that Symfony went through to create the web page you’re looking at. So you enter a URL and you don’t get the display you’re looking for? Take a look at the stack trace and hopefully you should be able to see where you’ve been going wrong. Not to mention that it also gives the the execution time and also the number of database querys (including the execution time for each).
If other frameworks are looking at improving their debugging method I’d really recommend taking a look at Symfony’s style as I can imagine it was/will be enormously useful in the future if I use this framework.

PHP and CakePHP

With some sadness I put away my Python programming hat and don my PHP programming hat (a felt trimmed fedora if you really need to know). I said I wouldn’t turn this into a programming language debate but Python is growing on me, and similarly PHP’s faults/quirks are becoming more obvious to me.
First in the PHP framework list is CakePHP, and this really does bring back some memories for me. It was one of the first frameworks I even tried to use on discovering web programming and the benefits of MVC. At the time CakePHP was one of the few PHP frameworks around and PHP was the only “web” language that was in common use with hosting providers so it was really the only choice, but has it stood up to the test of time and can it really compete with the features available to other frameworks around.

It should be noted that unlike Python, PHP is a templating language in its self so it’s not unusual for PHP frameworks to not having a different/pluggable templating language. That said there are many PEAR projects around that provide various functionality for use in web applications, ORM mapping, other templating languages, validation/etc. CakePHP gives no indication on the site of using any of these available modules, so I can only assume that like Django, CakePHP decided to roll their own layers for taking HTTP request and translating them into controller/model interactions.

Unlike Python frameworks that seem to require various libraries install into the system directory or at the very least some where in the Python path, CakePHP is self contained. Just download the latest cake version and expanded it to a folder accessible to your web server and you’re all set, provide of course that you have a web server with mod_php or similar installed.

Installing
As I said it was a simple extract to a folder. Or at least it should have been if I hadn’t tried to install the application into a directory that wasn’t the main web directory. I decided to create the PHP applications in a folder close to where I had tested the Python applications. I assumed that I could simply create an Apache directory, such as;

Alias /phpframeworks




This seems to come under the CakePHP alternative install, their first suggestion being that the CakePHP application being the only Cake application on the server. If like me you want to put your Cake application some where else you’ll need to edit a few files. For Cake itself you’ll only need to set this one, in webroot/index.php, but if you have mod_rewrite install and you want pretty URLs you’ll need to edit the .htaccess files as well. Certainly not one config to rule them all, but this is probably more of a problem with the way Apache and PHP integrate than with CakePHP itself.

tutorial
Yet again another Blog tutorial, clear/concise and quick. Covers the basics of creating a database, model, controller and the respective views, with a final mention of how to configure routing in a CakePHP application. And by quick/concise I mean, I hope you already know PHP and some MVC as there is no room for mistakes. I assume you know what a controller is know, because the CakePHP tutorial assumes you do too.

I have to admit it was refreshing after using the various Python frameworks to use one that doesn’t require any cruft. That is the model.php file contains only information relating to your model, you don’t have to import various models in order to enable certain features, they just work. Again this is more a PHP/Python thing rather than a PHP framework vs. a Python framework things, but when you are coding models/controllers it is good to be able to concentrate on the part you are working with without having to worry about making sure the underlying framework/libraries are linked properly.

On the downside with CakePHP seems to be no way of automatically creating database from your models. You have to create you database and then the model automatically associates with the database provided you have named you PHP model files correctly, or that you’ve linked your model with the table through a variable. It is possible to create models without having an associated database. On the one hand this is good because you don’t have to fill out your model with pointless functions that simple retrieve their associated data from the relevant table, on the other hand it means that application model is tightly associated with the database unless you say otherwise. Or more simple, as long as your good at creating databases you’ll be o.k, but don’t expect CakePHP to hand hold you through the SQL/Database part of creating a web application.

While there is no admin interface as there where in the Python frameworks I tried, you can specify that a Controller has Scaffolding. Basically this gives you an admin interface to the associated model allowing you to view/create/delete corresponding entries in the database without having to code anything. It appears that it may be possible to use the CakePHP command line application bake.php to create models/controllers/etc, but this isn’t well documented. edit Scratch that, I dug through the bake.php script, if you pass in the full path to your project directory you can use bake.php to create models/views/controllers by answering a list of questions.

By default CakePHP works through naming convention, that’s is you table is name X your model is named Y and your controller named Z then everything works o.k. by accessing the URL /A/B. Even better is the fact that for the most part these rules can be broken, a variable in your model can change the database table it points to, Routing can be used to customize the URL->Controller mapping and custom inflections allow you alter the CakePHP does it’s pluralization, singularization of class names. All the features I was looking for seem to be there, the only exception being the poorly documented and possibly feature lacking bake.php.

As the first PHP framework, CakePHP was a pleasing introduction. CakePHP itself is certainly well structured, easy to get up and running with (as long as you have a database already), minimal configuration with the possibility of overriding, easy to understand documentation and the Bakery seems to contain some interesting and useful code. The only thing I’d like to see improved with CakePHP is to see the same standard of documentation for bake.php and also the ability to create model function stubs (the stubs representing the database access methods) and be able to create databases from a model file. While CakePHP makes it pretty easier for a newbie to have a go at creating a dynamic site, not including a method of automatically generating a database from a model might be off putting.

Next Page »