Running Laravel Migrations on Heroku

Migrations are a really handy was of making database changes, be it schema or data, and keeping it in sync across multiple locations. They are however much more useful when automatic, so when they are needed to be run, they run. This helps prevent errors when you forget to run the migrations for instance. When using platforms like Heroku and tools like Composer, this becomes very easy. All that’s needed is to add the php artisan migrate –force command (–force … Continued


PHP Session Handling on Heroku

Most web applications use sessions of some kind for things like login systems, authentication, flash messages, etc. But using them on cloud services like Heroku can sometimes be a hastle. This post will hopefully outline some of the different methods you can use to get a fast, adaptable and easy session handler with PHP. Option 1) Single Dyno, Default Session (File) By simply running session_start(); with PHP, by default a file based session will start. This is great because it’s … Continued


Prevent your Site from being used in an iframe

Often as a security measure, it can be a good idea to prevent your site from being put within an iframe. This is a measure to prevent against click-jacking. It’s well supported in most of today’s web browsers – with support for: Chrome 4+Firefox 1.9+IE8+ This can be done by setting the HTTP header X-Frame-Options. Htaccess Header set X-Frame-Options DENY or in PHP <?php header(‘X-Frame-Options: Deny’); If you try and load the site with this header present, within Firefox you … Continued


How To Use jQuery 3 with a Fallback to v1 (for IE8)

With the release of jQuery 3 (and recently 3.1) we as developers have been able to use many new features – as well as having performance increases (at least visually). So it’s a no brainer to use it over previous versions, or is it? With the release of the v2 branch the jQuery team announced that it wouldn’t be supporting IE6-8. And… if you’re working on commercial projects, this sucks. Luckily you can use the latest version and fallback to … Continued


A MySql Backup Script (with Download Speeds & Hipchat Integration)

It’s a common problem we developers come across, we need to keep a backup of our databases so that if anything happens to our live database we still have a copy of the data. This is a quick script which uses the mysqldump command to grab a copy of a database and save it. It saves the file as a gzip file (because it saves a mega amount of space over time). More than just backing up the data, this … Continued


Make Your Own Compass with the Device Orientation API

Recently, while exploring the world of modern web APIs, I stumbled on the DeviceOrientation API which allows you to determine the exact position and rotation of a device, providing it actually has these sensors. This is especially useful when building mobile apps with technologies like Cordova/Phonegap because they allow access to functionality which would otherwise only be accessible through native applications. But it’s also useful in websites on occasions. To explore this API further I decided to make a little … Continued


How to Force the Download of a File with HTTP Headers and PHP

It’s quite a common scenario with the web to want to force a file to download, instead of allowing the browser to open it. This can apply to images, pdfs, html, anything a web browser can open (which is more and more these days). To accomplish this, we need to set some http response headers: Content-Type: application/octet-stream Content-Disposition: attachment; filename=”test.txt” Within PHP was can do this with a function like: function forceDownload($filename, $type = “application/octet-stream”) { header(‘Content-Type: ‘.$type.’; charset=utf-8′); header(‘Content-Disposition: … Continued


Install Let’s Encrypt on Ubuntu 14.04 / 16.04

There are many reasons to run a website with an SSL/TLS certificate (we won’t dive too deeply into them in the post). In the past they weren’t as accessible as they are now though, with the cost of a certificate varying immensely. Do you want to pay for a certificate, became a question you could ask when StartSSL began issuing free certificates. They have, however, had suspicion around their safety from time to time. Now there’s a new kid on … Continued


Direct Upload to S3 (with PHP & Composer)

This is a continuation in the ‘Direct Upload‘ series: First we began with a look at how you can directly upload a file to s3, talking it through in detail (13/10/2013). We later made another post, explaining how to handle multiple files and updating the code to use AWS’s signature V4 (7/3/2015). Now we’re back with another improvement! Instead of the copy and paste from a blog post solution we were advocating in past blog posts, we’ve now built a … Continued


SQL Searching with Relevance and Natural Language Processing

Working at a start-up in the early stages things are often built to solve a problem at the time, more often than not with a specific client in mind and time-frame in mind. As the company grows and becomes more established sometimes this very same code needs to scale or change based on features or performance original anticipated. One example of this is if your building your own search queries in SQL. We’ve all done it. They start out all … Continued


How to: Install PHP 7 on Ubuntu 14.04 / 16.04

It’s release day! Or it was on the 3rd of December 2015 – the release date for the final version of PHP 7.0. There have been a whole host of improvements made to PHP but we won’t delve too deep into changes. This is a very quick guide on how to update to the latest release for those of you running a Ubuntu Linux system. It is very simple, thanks to ondrej managing a ppa repo for this release, like … Continued


Enabling HTTP/2 Support on Apache2 and PHP

I’ve been a keen follower of the exciting changes to the HTTP specification over the past few years – with the release of the HTTP/2 standard in 2015 (after it evolved from the spdy project). If you’re unfamiliar with http/2 there are some great videos available which outline exactly what it is and how it is different from http 1.1 – which we’ve been so accustomed to over the years. In light of these changes and of the ever increasing … Continued