Skip to content
Photo of Chris Hogben

Chris Hogben

PHP and Laravel developer with technical leadership experience.

All posts

5 min read

Some of the worst code I have ever written may exist forever

Back in 2005, I wrote some code to solve a problem and it did everything I needed it to, and as there was nothing else like it, I decided to open source it so others could benefit. This decision led to a chain of events that means my code may outlive me - and it is absolutely terrible code! But do I regret doing it and would I do it all again today?

  • Blog
  • Personal
  • Code
  • Conferences
Aaron Francis and James Brooks on stage at Laravel Live UK 2026
Laravel Live UK

In June, I had the pleasure of attending the largest annual Laravel conference held in the UK - Laravel Live in London.

This event sees hundreds of Artisans from across the country (and the world!) come together for two days of amazing talks on the Laravel framework and wider ecosystem. It gives a fantastic opportunity to socialise and network with others in the community. As always, the speakers and topics were outstanding, with lots of ideas and thoughts flowing from talk to talk and I was grateful to be able to speak to numerous people about their organisations, applications and projects.

At the conclusion of the second day, an end-of-conference social gathering takes place upstairs at O'Neill's, a traditional British pub across from the auditorium and close to St Pancras railway station. A group of us were sitting at a table overlooking the Euston Road and the surrounding buildings, and the topic of the British Library was brought up.

Street view from Euston Road showing O'Neill's pub on the left side of the road, and the British Library on the right
View from Euston Road with O'Neill's pub (left) and British Library (right) / Google Street View

The British Library receives and preserves copies of works published in the UK under legal-deposit rules, as well as a large number of those published overseas too. It is the British equivalent of the Library of Congress in the United States. If you are looking for a book, there is a very good chance that they have a copy of it somewhere in their collection - no matter the topic.


Which brings us back to the discussion, where I had brought up the topic of some code I'd written that had ended up in print.

In 2005, I was still at college working towards my vocational qualification in software development. A friend of mine had started a web hosting business on the side and was using a well-known online payment service for receiving payments. Unfortunately at the time, this required hosting a plain HTML form with hidden input fields denoting price, return URL, and other information that you probably shouldn't be allowing users to edit, or perhaps see!

To overcome this, I wrote some PHP code in a reusable package - PEAR style - that made use of a relatively new piece of functionality that used an RSA key pair to encrypt the metadata using public-key cryptography, allowing all the hidden input fields to be replaced by one containing a Base64-encoded version of the encrypted metadata. This made the payment metadata harder to tamper with and reduced the possibility of someone tweaking the price to a penny.

At the time, I was happy with the code I had produced. It did what it set out to achieve, and it was written in a way that others could easily make use of for their own projects. I posted it as a package, released it under an open-source licence and thought nothing more of it.

A couple of years later, I learnt that the code had been adapted for and published in a book. Yes, an actual, physical book. Somehow, my code had technically made it into print. The author was kind enough to send me a signed copy, which I still have to this day.

Does this mean the British Library has a copy of the code I wrote back in 2005? Maybe. If it does, it's going to have quite a long shelf-life!


During our discussion at the Laravel Live social I managed to find and pull up the code in question - it was awful. Redundant docblocks littering the code, shell_exec() usage throughout with little to no thought about escaping arguments, race conditions galore and extremely poor error handling and reporting. It's amazing to think it ever worked at all.

This then got me thinking - do I now regret putting this code out into the wild? No. I don't.

I was proud that I had overcome a problem. I was excited to be one of the first people to write a solution for the problem in PHP. I wanted to help others. I didn't care what anyone else would think about it.

Is this the right mindset to have today? Two decades ago the software landscape was significantly different - today we have security front of mind, we try to support and improve code that is shared with the world, and opinions are more vocal than ever. These considerations should shape how we publish and ship, but they shouldn't stop us from doing so. With today's tools we can get near-instant feedback on our code from all kinds of perspectives, allowing us to have greater confidence that what we are putting out there has been tested, considered and is safer to share.

If I can get awful code put in print, what stops you from pushing that code you have to a public GitHub repo? Could someone else benefit from some code that you've written? Share it! Even with the advancements in AI, the world still needs open source code. You never know where it might end up...

Three people (incuding myself) reacting to a shuffleboard game at the Laravel Live UK Social event
Laravel Live UK