Frequently Asked Questions

💡️ Obviously these aren't "frequently asked" questions - no one's ever going to email me and be like "Hey, wow, yeah really loved reading your blog but it made me wonder, what database system is it running on and also what coffee-making apparatus do you recommend?"

It's basically just an extension of the About Me page but in question-and-answer form, because it's more fun that way. But if you do have a question, feel free to email me. I'm happy to count once as frequent for the purposes of this page.

PHP

Isn't PHP old hat now and just for beginners?

Goodness, no! This is a common misconception, partly brought about by ill-informed snobbery in some other programming communities and partly by some genuine historical issues with PHP as a project and language.

Unfortunately you will sometimes hear people say things about PHP which are untrue; that it's poorly designed, insecure, not properly maintained or not suitable to cope with the serious demands of modern web applications. The people saying this usually haven't used any PHP version released in the last decade.

A combination of the way the language evolved and was built up ad-hoc over the years, initially developed with both the intention of being easy to learn and limited in scope to pre-processing web pages, plus a couple of what were in hindsight bad choices (which have since been corrected) have earned PHP a bad rep.

I'm not saying there aren't a number of things about it you can still criticize today - the same is true of any language. Nor is PHP suitable for any and all use cases. But the bottom line is PHP 8 is a robust, very powerful, very fast, scalable and versatile programming language and becomes more so with every new release. Anyone who tells you otherwise, as far as I'm concerned, doesn't know shit about PHP.

Is this website built with PHP?

It is indeed, as is most of the entire web. My site is a simple blogging system I built using what in my opinion is by far the best PHP framework for web professionals - Symfony.

Another highly popular framework is Laravel which I would say is easier for beginners to learn, but lacks some of the power and flexibility of Symfony. It's a more opinionated framework and does a lot more "magic" behind the scenes to hide details from you and allow you to push out a site more quickly. This is great until you either reach the need of a more complex, larger scale system or want a finer degree of control over your architectural choices, at which point I'd argue Symfony starts to win out.

For a simple application like my blog, Laravel would also have been a fine choice, I'm just not personally as fond of working with it. If you're new to PHP, though, I'd probably recommend building your first site with Laravel over Symfony.

The website content is written in Markdown and the site is structured to auto-generate more or less everything else, including the table of contents you see on the left on each post. No need for fancy WYSIWYG editors or a back-end cluttered with plugins, I just log in, type in my shit, click to save and I'm done.

So, how about WordPress?

Ahh, WordPress. In one sense, probably PHP's biggest success story (it powers literally tens of millions of websites), yet also responsible for a lot of that myth about PHP and those who use it being terrible. Unfortunately there is a lot of bad 3rd party code in the WordPress ecosystem and the platform itself continues to be built on outdated architecture.

My feelings about using WordPress can be summed up by the fact it was preferable to me to just build my own system from scratch for this site than to do it in WordPress (and probably just as quick if not quicker than customizing WP to my liking) - but I will say this, if you're going to use it, use it as a blogging platform like it was originally intended. Don't try to use it as a more complex CMS, e-commerce system, forum, social media site etc. You may be able to fudge these kinds of functionality together with plugins but there are better, dedicated systems for those use cases.

What database does your site run on and also what coffee-making apparatus do you recommend?

The normal thing to do with Symfony (and what I would usually do in the real world) is use the Doctrine ORM to define your application's persistence models with a relational database or, if your architecture targets NoSQL, MongoDB.

This website actually uses my own DocLite system, which is a PHP NoSQL database built on top of SQLite, designed as a reasonable mid-point between flat-file stores and bigger systems like Cassandra or MongoDB. It's primarily suitable for small to medium scale applications, or situations where your requirements are evolving and you don't know what your eventual models will need to look like. I encourage you to check it out, with the caveat that it remains a work in progress.

I could have made my blog with a plain, structured SQLite database of course, but it'd be ridiculous for me to not have my own product in production somewhere. Turns out it plays very nicely with Symfony too.

Oh and for ☕️, having been through just about every coffee-making device on the market, I heartily recommend an espresso machine. Even a cheap one (circa £50) will make a far tastier coffee than any alternative as long as you use it with freshly ground beans.

Tell me a bit more about this DocLite database?

Gladly! DocLite is a PHP NoSQL database built on top of SQLite. Basically it's a library which allows you to treat a local file as a NoSQL JSON database, taking advantage of SQLite's JSON1 extension to do the heavy lifting in parsing, querying and indexing collections of documents.

I threw it together in my spare time as a more powerful alternative to local, flat-file stores like SleekDB.

Written over a few spare evenings in lockdown, it remains a work in progress. It's not perfect, almost certainly not bug-free and there's more features and improvements I intend to add to it in future. But I do consider it stable enough now I'm happy to unleash it on the world as open source.

Why SQLite, why not MySQL or PostgreSQL?

Because the vast majority of websites and web services (probably 90%) would run absolutely fine on SQLite. It can handle powering a site getting tens of thousands of hits a day (which I can assure you, this one doesn't).

MySQL tends to be the default choice which goes hand-in-hand with PHP, primarily because the community edition is free, it's easy to configure and learn, performs very well for high numbers of concurrent reads and gives you the benefit of a dedicated database server. There are many reasons why you might want that advantage; horizontal scaling, replication, access control, concurrency demands and distributed connections are a few which come to mind. But none of these apply to my blog.

Postgres is what you use if you're serious about your data but not quite to the extent you need to pay for Oracle, it's a way more feature-rich and power-packing system than you need for the average small site.

How do you remember the inconsistent order of parameters to all those built in functions? Looking at you, needle and haystack...

I don't. I either look them up in the manual, or let my IDE tell me. I hear you, though - some of the historical inconsistency in PHP's internal functions is mildly annoying. It's one of those things you can legitimately criticize about the language.

What IDE should I use for PHP?

If you don't want to pay for one, I recommend Visual Studio Code as the best free IDE.

If you want what is in my opinion the best IDE, PHPStorm without a shadow of a doubt.

What do you not like about PHP?

I'd love to see all those internal str and array functions be replaced with String and Array object types one day. Maybe we could even natively differentiate between strings and sequences of bytes.

Other than that, there are features PHP doesn't have (yet) which would be cool; native async, decorators, and generics to name a few I'd like.

Technology

Android or iPhone?

Android all the way, baby. I like my tech open source where possible and value for money. Most of Apple's stuff is not the former and I don't personally consider it to be remotely approaching the latter.

Why isn't my printer working? Where's this menu gone on my television after it updated? How do I make those fancy coloured tables in Excel?

I don't know. Yes, I "work in IT", that's a damned vast field and many years of practice have given me a specialized grasp of one small corner of it.

Windows or Linux?

For day to day home PC use? Definitely Windows, which is probably against the grain of the answer most developers would give you. But honestly, since Windows 10 came out, I've just never had the problems with it I see other people complaining about and with the addition of a genuine Linux kernel in the Windows Subsystem for Linux (WSL2), it's pretty great for developing on too. I also like to play a few games which don't necessarily run well (or at all) on other systems.

I'm entirely comfortable using an Ubuntu desktop and administering any of a few flavours of Linux for a server (and I would say always deploy your PHP applications to a Linux server, unless you have a particular reason not to). I used to run my home machines as dual-boots between Ubuntu and Windows but I just don't really get a benefit out of doing that any more. I can quickly spin up a VM in Hyper-V on the rare occasion I might need to.

Personal

Why do you have ads on your personal website?

Some of my tutorials score very well on Google searches. Although my site is not nearly popular enough to earn significant revenue from ad exposure, it may surprise you to learn I make just about enough to cover the annual running costs. Apologies if you find the ads intrusive, but the occasional click helps support my blogging efforts.

How did you get in to programming and web design?

When I was a small child, I was fascinated by computers. They were like the ultimate toy, you could make them do anything. And the ones we had at the time were seriously basic by today's standards; the first PC I owned was a 386 running DOS with 2MB RAM and something like a 40MB hard drive but it was great for the games of its generation and learning to use a command line at such at a young age was a definite advantage for my future career.

I'm not exactly sure why, I just wanted to know everything about how they worked and in particular how software worked. How was it you could "write programs" for these machines and they could remember your instructions and do them again the next day and the next? How were programs written? If you needed a program to write a program, then how was that program written?

So I started learning everything I could. I wrote my first programs in QBasic, then later (around age 11 or 12) some simple programs in C. When I got online in the mid-90s, I started making simple web pages (HTML and browser technology was also very lacking at the time compared to today, shout out to anyone else who remembers trying to get their design to work with complex table layouts and frames).

Really just went from there. I taught myself about algorithms and data structures from (mostly second hand) books, I examined source code other people had written. When I was 16 in college, I did my first major project in C++ - it was an interactive Windows program which displayed a chess board and solved the Knight's Tour from any starting position you chose.

Some time around I think 2004 I wanted to make an interactive rather than static website. This was when I first discovered PHP and taught myself that too, as well as how to manage my cheap VPS and Apache. Much of what I've learned since then has been on the job over fifteen years. I still consider it a bad year if I can't look back on at least one thing I did in the last 12 months and think "wow, that was terrible, why did I think that was a good idea?", though. No matter how much experience you have, learning never stops. Neither does forgetting whatever you don't put in to practice; I have long-since forgotten how to write C++.

What television series do you recommend?

Oh wowzers, like so many, new and old. Recently I've finished Deutschland '89 (this and its two predecessor series are probably the best foreign drama I've seen), The Queen's Gambit, Bridgerton, Cobra Kai (if you were a fan of the original Karate Kid movies, you simply need to see this), The Morning Show...start with those, let me know if you need more recommendations after!

I am the proud owner of a Star Trek captain's hoodie, complete with com badge, but my fanship is to the 90s series; TNG, DS9 and (to a lesser extent) Voyager. I didn't actually enjoy the original series, which undoubtedly makes me a heretic and not true Trekkie in many fans' eyes.

What is your favourite food?

Pizza 🍕 - you ever get that thing where you shop somewhere so much, you build up a rapport, get to know the person on the checkout and end up on familiar, first name terms? I'm like that with my local pizza place. But I'm also very partial to spaghetti bolognese, or my own chili and prawn linguine (the secret is I make it with lemon juice, everything is made better by lemon juice).

Recent posts


Sunday 01 December 2024, 18:37

Re-examining this famous puzzle of probability and explaining why our intuitions aren't correct.

musings

Sunday 17 November 2024, 22:53

Keep your database data secure by selectively encrypting fields using this free bundle.

php

SPONSORED AD

Buy this advertising space. Your product, your logo, your promotional text, your call to action, visible on every page. Space available for 3, 6 or 12 months.

Get in touch

Sunday 27 October 2024, 19:02

Learn how to build an extensible plugin system for a Symfony application

php

Saturday 10 February 2024, 17:18

The difference between failure and success isn't whether you make mistakes, it's whether you learn from them.

musings coding

Monday 22 January 2024, 20:15

Recalling the time I turned down a job offer because the company's interview technique sucked.

musings