My Broadband provider does not support fixed IP addresses. So for a long time now, I’ve been regularly updating my Digital Ocean firewall to grant SSH access to my local network. A chance conversation with my brother introduced me to dynamic DNS … and a rabbit hole that I thought worthy of a quick write up!
At first I thought that all I need was a dynamic DNS setup, and a means to automatically update what that pointed at when my IP address changed. However, it turns out that Digital Ocean firewalls do not support domain names in the rules…
You can throw Exceptions, but can you catch them nicely for your users?
Having logic in your controllers to handle unexpected external issues can make your controllers ugly and difficult to manage. Accordingly, Laravel provides the exception handler by default at
App\Exceptions\Handler. This does all sorts of handy wrapping, and is great for reporting (bugsnag, honeybadger etc use this). But a handy feature I recently discovered is that if you create custom exceptions with a
render method, it will use that to produce a response for your users.
This means that you can keep the end result of your custom…
A while back, I made a custom faker provider in my Laravel application to provide support for some tweaks I needed to make to some image generation. I pretty much cribbed it from this SO Post, which provides great detail as to how to set it up with a service provider, and your factories can immediately use any of the new functions you define.
However, this evening I needed a new faker function directly inside my tests, and discovered that the
WithFaker trait didn’t create the Faker instance in the same way, not picking up on my additional faker methods…
In the ongoing refinement of my CI pipeline for my projects, I’ve been working on triggering automated deployments when my tests pass. A fairly standard thing to do, but not one that is supported out of the box by my current set up of using CodeShip Pro for my test suite, and DeployHQ for deployments.
To resolve this, I would need to create a new step at the end of the Codeship CI process that would be able to trigger the webhook on DeployHQ environment. This would require the following:
Having a webpack build process of your assets is pretty standard, but what happens when you need to include files from angular-cli as well?
However, requirements just kept on growing, the jQuery got more complex, and finally it got so complex that any small change left…
I Came across a weird problem with a test today. Am working fast through a site I am building in tandem with another dev, and wanted to ensure that the routes that need to be behind the authentication middleware are actually protected by them. I thought my first effort would cover things easily enough:
$response = $this->get(route('foo.bar'));
But instead I got the following result:
Response status code  is not a redirect status code.
Failed asserting that false is true.
It seems that the
auth middleware uses metatag based redirecting rather than sending the 302 Status Code with a…
Recently, we’ve needed to update our user model in our django project to support additional properties. Having looked at this great post about extending the user model, it was clear that at this point we needed to simply create a
Profile object with a one to one relationship on the
User model. I duly followed the approach outlined, creating a signal that would automatically create a
Profile object when a
User was created:
def create_user_profile(sender, instance, created, raw, **kwargs):
if not raw:
(possibly worthy of note is that I didn’t create separate signals…
I have an application that I wrote in Laravel 5.1 a couple of years ago. It has a suite of tests at the unit and integrated level, and full Selenium based testing courtesy of the now defunct
Laracasts\Integrated package that was an early precursor to much of the testing tools that are now part of Laravel 5.4.
This article is not about the details of the various testing packages and the constantly evolving world of test support in Laravel (as fascinating as that might be to look at). …
Having worked my way through getting Laravel Dusk working on my current project (with a quick sidestep into getting it working on Homestead as well), I figured it was finally time to start working with Dusk to write some actual tests.
On earlier projects I have worked on, there was a whole bunch of pain points to getting selenium up and running, and having the tests developed. In all honesty, I steered clear a lot of the time and let other people take care of it. …
Having been playing with Dusk for the last couple of days, I became aware that several people were trying to use it in a slightly different way from my approach. Several people were asking on the testing channel on Slack about how to get it working on Homestead. Having managed to get it running on Codeship, I thought that people would be able to simply apply the changes I had made on Homestead. Turned out there was a little more setup to do.
I have only quickly pieced this together in a single project environment, so there may be some…
just some guy, y'know?