Amo Chohan wrote a very good article detailing a technique he uses to clean up controllers when dealing with complex search queries in eloquent. I’m also enjoying Adam Wathan‘s latest release: Refactoring to Collections – a read guaranteed to make you smarter. Amo really nailed the functionality here – but I think the final class… Continue reading Refactoring Advanced Eloquent Filters To Collections
Blog
Stress Testing a Website with Throng
I recently needed to stress test a website to ensure that it could hold up in the real world – after some searching I stumbled upon Throng – a simple app for Mac. It allowed me to hit my website with concurrent requests for a specified period of time. You can download the 7-day trial of… Continue reading Stress Testing a Website with Throng
Creating an Embeddable Javascript Widget
One of the updates I’m working on for WhichBeach is the ability for other website owners to embed WhichBeach widgets that will display up-to-date beach data. This is very much a work in progress, but I’d like to share. I’ve never done anything like this before, so I thought I’d start by taking some inspiration from… Continue reading Creating an Embeddable Javascript Widget
Applying Text Transform to Form Inputs
I often find myself in the situation where a design calls for form inputs to transform the user’s text. It’s pretty easy to do nowadays: This is what it looks like: But – I’ve always found these types of interactions frustrating whenever I come across them. The expectation of the user is jarred when the… Continue reading Applying Text Transform to Form Inputs
Immutable Objects Will Improve Your Life
Learning about immutable objects improved my PHP code thoroughly. I’ve listed some helpful resources below that really helped me grasp the concept of immutability and value objects. As a quick example, if your code sometimes looks like this: When it should be looking (more) like this: Then I urge you to read up on immutable objects.… Continue reading Immutable Objects Will Improve Your Life
Logging Guzzle Requests
When you’re building an API consumer, you should log your API requests and responses. Otherwise it can feel like you’re working blind. Here I’ll explain how to configure a Guzzle Middleware to log requests to a file. This is useful for debugging and historical purposes. The way to do this is to pass a new HandlerStack with our logging middleware… Continue reading Logging Guzzle Requests
Pushing Logic to Custom Collections
This is a technique that I recently found useful. Eloquent models allow you to specify a custom collection object to be returned – which sometimes can be a great place to put some business logic. While refactoring WhichBeach, I used a custom collection to move some logic from the Beach model to a custom BeachCollection.… Continue reading Pushing Logic to Custom Collections
Don’t Build Salmon Cannons
Today I learned about Salmon Cannons. Salmon have evolved to swim up river to spawn, but the introduction of dams has created a sometimes impossible obstacle for salmon to overcome. A clever solution has been found in the way of the Salmon Cannon – a slippery tube that sucks salmon over obstacles so that they can… Continue reading Don’t Build Salmon Cannons
Things I Used To Do (That Aren’t Cool Now)
I’m the proud owner of WhichBeach – the website that tells you which beach is best to visit (in Malta) based on the weather, updated hourly. As I’m picking up the codebase ahead of this Summer’s updates, I can’t help but review and refactor the existing code. It’s interesting to dissect previous design decisions. Also, I’ve learnt… Continue reading Things I Used To Do (That Aren’t Cool Now)
Setting the default value of a select tag in Vue.js
I recently came a cross a small stumbling block when rendering a select box from data passed to my component via props. This is my component: And I’m including it in a parent Vue instance like so: The Problem I want to be able to set the selected tag from my parent instance. This works… Continue reading Setting the default value of a select tag in Vue.js