This is a brief introduction to Unit Testing with PHPUnit and is based on a lightening talk I gave at Sheffield PHP on the 18th January 2018. We’ll take a look at what unit testing and PHPUnit are, why we would use them and finally look at how we can start writing tests.
How I solved issues with Laravel Mix’s image optimisation.
A quick look at how to set multiple rulers in Sublime Text 3 to help keep code readable using differing line widths to indicate soft and hard line length limits.
Whilst working on a site I’ve been developing using a Laravel Homestead Vagrant box I discovered that the box’s clock had drifted out of sync with my laptop by about 10 minutes. Normally this wouldn’t be much of an issue for me, but in my case I was trying to authenticate via an API using OAuth and that time difference was causing the authentication to fail. The solution to my authentication issue was to reset Homestead’s clock to the correct time, but obviously over time this would likely go out of sync again.
The other night I downloaded a fresh install of Laravel 5.4 using Homestead as my development server and quickly hit upon issues running Mix, Laravel’s Webpack API.
If you need to order results from a MySQL query by a specific field value first then there’s a couple of approaches you can use. Let’s use as an example a table of countries where we want to order alphabetically but put the United Kingdom first.
PHP traits provide a convenient means of sharing methods between classes. There are times though that we may need to override or extend a method defined in a trait attached to a class. Let’s take a look at how we can achieve this.
Using CDNs is great for improving site performance and lowering bandwidth usage on your server. However, they can also open up a security hole in your site. Troy Hunt has written a great piece about how you can protect your embedded content with subresource integrity.
The SRI Hash Generator website is a great resource for getting started with using subresource integrity (SRI).