Posting to Bluesky via the API from PHP – Part One

With all the uncertainty surrounding the future of X (née Twitter), I decided to take a look at Bluesky which somewhat ironically has its roots in Twitter where it was started as an internal project. Bluesky is still in beta and is invite-only. I worry about its long-term given that ultimately it too has to make money, something that Twitter has singularly failed to do. None of this, of course, affects the topic today which is posting to Bluesky via the API.

Basic Concepts

The first thing to say is that I am using the following library to actually post … Read the rest

Sending messages to Pushover from PHP

One of the things that I regularly bake into my own applications is notifications of when things go really bad and need my immediate attention. For this, I use the excellent and simple Pushover service which allows me to send a push notification to my mobile device. In this post, I run through how to set up your application in Pushover and then send a notification via PHP.

Setup Pushover

I am assuming that you have already created your Pushover account. You get a 30-day trial and after that, it is just $5 as a one-off purchase.

From your dashboard … Read the rest

Changing the Default PHP Version in MAMP

When doing any development on my laptop I use the very useful MAMP to give me an xAMP (Apache, MySQL & PHP) environment.

I recently upgraded and found that the free version offers two versions of PHP: 7.4.33 and 8.2.0 which would be fine but my production server is still on 8.1 and so I needed to match that. I could have upgraded to MAMP Pro but £90 just to switch to PHP 8.1 seemed a bit much, although, I do appreciate that by doing so I would be supporting the developers.

Changing the PHP Versions in MAMP Free Edition

Read the rest

Setting the Codeigniter Environment for both CLI and Browser

I’ve recently been getting to grips with the Codeigniter framework after years of using a home-grown monstrosity. I was becoming more and more concerned about the level of security in my own framework and decided I would be better off with something that’s maintained.

I researched the many PHP frameworks to find one that was going to work for me. I toyed with the idea of using Symfony, which is what our products are based on, but the time to get up-to-speed with it was greater than I wanted to invest. I therefore settled on Codeigniter which looked easier … Read the rest

Using Google Translate to Automatically Translate a Symfony Language File

Recently the company I work for launched a new version of our product with multi-language capabilities. This was great for us but when we wanted to expand out to other languages we found that it was expensive to have the file translated.

Given that our language file is in a standard format (Symfony’s message YML format) we wondered if it would be possible to convert the file automatically via Google Translate and then give it to a translator to polish. It turns out that it is and this is quicker and cheaper than having all the file translated … Read the rest

Raspberry Pi GPS tracker – Connecting Without a Network

All articles to date have been about getting the GPS working with the Raspberry Pi and converting the original Python code to PHP. All of this works well (for me) but what if you want to make changes to the settings or download the log file while you are out and about and away from your home network?

Normally what happens is that you configure your device to connect to a known network but as you are going to be using the GPS/Pi combination away from known networks you need a way to access anywhere without having to connect a … Read the rest

Raspberry Pi GPS tracker – Converting Code to PHP – Part 2

In the last post I looked at converting the original Python code to PHP. This all ran without issue but I quickly found that because the Pi wasn’t connected to the internet the date and time of the device never got updated. This meant that the log files always had the wrong timestamp when they were created making it difficult to find the one I needed.

Turns out that there is a simple answer to this problem. As the GPS satellites include the current date and time as part of the detail that is sent along with the location we … Read the rest

Raspberry Pi GPS tracker – Converting Code to PHP – Part 1

Last week I looked at getting the hardware up and running for a Raspberry Pi GPS tracker. However, as I said I was using some Python code and I don’t speak Python so I wanted to convert it to PHP. So this week I am going to look at what I did.

Before I could even begin to look at the converting the code I had to see if it was even possible for PHP to access the serial port. Turns out this is exactly what Direct IO (dio) is for but it isn’t included as standard so you … Read the rest

Raspberry Pi GPS tracker – Getting it Together

Having secured a Pi Zero from the cover of a the magazine MagPi I thought I would start out simple by trying one of the projects shown there. The one that caught my eye and required no soldering was to build a GPS tracker.

Getting hold of a cheap USB unit was pretty easy but make sure it is Linux compatible. I bought this one from eBay.

The first thing I did when I got the unit was to try it out on the Pi and while it was working I could see that it had got a satellite … Read the rest

Using Kindlegen with PHP on Linux to Create Kindle Files

I’m working on a side project at the moment that requires the conversion programatically of a page of html to something that can be consumed by an Amazon Kindle. I did a quick search to see if anything existed as a PHP class library that I could use and while there was they were either hugely bloated or too alpha for my needs.

I then stumbled upon Amazon’s command line tool KindleGen which allows conversion of HTML and ePub docs to the MOBI format that the Kindle requires. This is a multi-platform too and, crucially, a version for Linux is … Read the rest