It's the second and final part of how to build a simple API in PHP. To recap, part 1 covered setting up the basics and using the Symfony Routing component while the additional part 1.5 covered using the Symfony dotenv component to store our API's config.

I ran into this error on a brand new Digital Ocean machine recently. It's one of those things you end up really confused about but the solution is simple.

Ansible is a great, simple to use tool for managing servers. Here's my provisioning script that can be used across Debian dedicated and virtual servers. It does a lot of the standard things like setting up the firewall, creating a non-root user and copying across SSH keys.

If you have a single IP address and are using Proxmox, you're probably using NAT. The common advice is to put your iptables rules in the interface on the post-up and post-down commands. But this comes with a big problem. If you add additional rules (e.g. to forward ports on a new VM) you need to restart the network bridge. Doing so results in all running VMs dropping their network connection and they need to be rebooted. Not good. Here's my workaround.

Having witnessed the carnage of not having adequate backup strategies, I've more than recognised the importance of simple and reliable backups. There are no backup products (as such) in use here and no data deduplication, just some bash scripts, a cloud storage provider and rclone. The end result is a local and remote copy of tarred and gzipped backups that are stored by day, by week and by month, retained by a definable period. The backups contain the web folders, the Apache virtual host configs and the MySQL dumps.

A few days ago, the Bootstrap 4 beta was announced. Bootstrap 4 alpha was released 2 years ago so what happened? Well as the author admits, there were copious rewrites, including going from optionally supporting flexbox to requiring flexbox along with dropping IE9 support in the process. Is that release cycle way too long? Yes. A lot has changed in 2 years and in some ways BS4 feels outdated already. CSS grid support is getting better rapidly and Bootstrap makes no use of this, as are features like native CSS variables. I understand they want to continue IE10 support but as usual the cost of doing so holds so much else back. It remains to be seen where Bootstrap will continue to remain popular or whether other lighter frameworks like Bulma might take over.

Okay it's going to be a slight departure from our planned next step on our API because I realised we need to store our database credentials somewhere and it seemed like an ideal opportunity to try out the Symfony dotenv component. This component reads values from a specified config file into environment vars. Using environmental vars helps separate credentials from code and keeps them out of a source control system. But why do you need a component to help with this? Well it's an extra convenience in dev and staging setups. It means theres no need to add any extra config outside your project and it adds improved portability (this method works with Apache, Nginx, PHP web server etc.). You shouldn't be using this component or an .env config file on production systems. Anyway, it's really simple to use, let's set it up.

For a project I'm working on, I need to write a simple API in PHP to fetch data. This is part 1 of the setup of the API in which we discuss Composer and the Symfony HttpFoundation and Routing components.

I have built a few static sites recently and one of the quickest ways to get them going is to take advantage of gulp, handlebars and npm, and roll your own simple static site generator. Handlebars is powerful enough to support the idea of layouts and makes it easy to build sites in a structured way without code repetition. By using gulp we can also easily take advantage of using sass, imagemin, js minification and more.

Everyone knows getting emails to land in inboxes is much harder than it used to be. If, like me, you rely on using the mail command to send emails from cron jobs and scripts, mainly to alert to failures, it is important those emails end up in your inbox and not in spam. Today lets take a look at ways to achieve this.

As part of my backup strategy, I have decided to upload my backups to BackBlaze (a relatively cheap cloud provider). These web backups do contain sensitive data and until now I have not encrypted them. However that's about to change! Encrypting files on Debian isn't something I've done before so I'm documenting my process for future reference.

A quick problem I ran into today with sending mail from a VPS with IPv6 enabled to a Google email address.

Uh oh. Woke up on Sunday morning with an email from to inform me my website was down.

Recently I managed to get hold of a KS1 from Kimsufi. They're a challenge to get hold of as they're so popular but they are great little machines: Atom N2800, 2GB RAM and 500GB disk. The drive has 32962 power on hours, so been around for a while but seems healthy. If you want to get hold of your own KS1 or any popular and often out of stock Kimsufi machine, I'd recommend Check OVH. Anyway these machines are great for torrenting Linux ISO's and that is what I intend to use it for... Below is a simple guide on getting everything set up using Deluge Web UI.

Because I never remember how to do this, here's the process for installing new locales on Debian. In this case we will be installing a Spanish locale.

Sometimes I need to duplicate commits across multiple git repositories. As with a lot of things in git, there's more than one way to do this.

Recently I noticed I've not been able to paste Unicode characters into an ssh session when using Cygwin. Pasting them into the terminal locally worked fine. Here follows how to determine the issue and the simple solution.

As I continue my attempt to learn vim, I thought it was also time to put my common dotfiles in git so it is easier to transfer the configuration from machine to machine.

For better or worse, I am making a significant effort to learn vim. No more shall I reach for the mouse to change some text or add a bracket! Ultimately my goal is not to necessarily stick with vim, but to be familar enough with its shortcuts to be able to switch to vim mode in another editor - perhaps Sublime. Perhaps even Visual Studio Code. Below are my notes on key keys, I plan to add to this as I learn new features of vim. I am also reading vim for humans, it focuses on making vim usable rather than teaching you the intricies and it is a good read if you want to be productive from the get-go. Along with this I did vimtutor which is a useful primer on vim shortcuts.

I have started to use Deployer a task runner/deployment tool written in PHP for deploying my site in a single command.

For some reason, GitHub doesn't show you stats at an organisational level. I have been interested in seeing total organisational commits by committer for a while now so decided to grab this data from the GitHub API. Turns out, as always, it's not quite that simple.

Getting a perfect score on Google PageSpeed Insights can be a frustrating experience, often due to their no render-blocking JS and CSS rule. However with one simple trick (quite literally) all is solved!

Do not adjust your monitor. It is actually a new site.