Creating custom assertions with PHPUnit
Today I’ve been working on a library I’m building for making it easier to build RESTful API’s with Laravel. It uses an abstract RESTful controller, which inherits from the default Laravel controller,...
View ArticleBuilding a postcode lookup client with HTTPlug and PHPSpec
While PHPUnit is my normal go-to PHP testing framework, for some applications I find PHPSpec superior, in particular REST API clients. I’ve found that it makes for a better flow when doing test-driven...
View ArticleFull text search with Laravel and PostgreSQL
I’ve touched on using PostgreSQL to implement fuzzy search with Laravel before, but another type of search that PostgreSQL can handle fairly easily is full-text search. Here I’ll show you how to use it...
View ArticleUsing UUIDs as primary keys with Laravel and PostgreSQL
For many applications, using UUID’s as the primary keys on a database table can make a lot of sense. For mobile or offline apps, in particular, they mean you can create new objects locally and assign...
View ArticleCreating Artisan tasks that generate files
While the documentation for creating Artisan tasks is generally pretty good, it doesn’t really touch on creating tasks that generate new files. The only way to figure it out was to go digging through...
View ArticleUsing Artisan from standalone Laravel packages
Recently I’ve been building and publishing a significant number of Laravel packages, and I thought I’d share details of some of them over the next few days. Artisan Standalone is a package that, when...
View ArticleA Laravel package boilerplate
The second package I’ve been working on recently is Laravel Package Boilerplate. It’s a basic starter boilerplate for building your own Laravel packages. It’s not meant to be installed as a project...
View ArticleAdding dynamic flat pages to your Laravel app
Most web apps have at least some need for some additional flat pages, for purposes such as: Terms and conditions Cookie/privacy policy FAQ You can of course hard-code this content in a view file, but...
View ArticleMore tricks for speeding up your Laravel test suite
When you first start doing test-driven development with Laravel, it can be quite hard to produce a test suite that runs quickly enough. The first time I used Laravel for a large project, I had a test...
View ArticleAdding comments to models in Laravel
Laravel Comments is a package I recently released that allows you to add comments to any model in your application. Possible models you could use it to enable comments on might include: Blog posts...
View ArticleCreating an Artisan task to set up a user account
When working with any Laravel application that implements authentication, you’ll need to set up a user account to be able to work with it. One way of doing that is to add a user in a seeder, but that’s...
View ArticleGetting the type of an unsupported Postgres field in Laravel
Today I’ve been working on a generic, reusable Laravel admin interface, loosely inspired by the Django admin, that dynamically picks up the field types and generates an appropriate input field...
View ArticleCreating Laravel Helpers
Although helpers are an important part of Laravel, the documentation doesn’t really touch on creating them. Fortunately, doing so it fairly easy. Here I’m building a helper for formatting dates for the...
View ArticleEasy repositories and decorators with Laravel Repositories
Creating repositories for your Laravel models, as well as creating caching decorators for them, is a useful way of not only implementing caching in your web app, but decoupling the application from a...
View ArticleAdding OpenSearch support to your site
For the uninitiated, OpenSearch is the technology that lets you enter a site’s URL, and then press Tab to start searching on that site - you can see it in action on this site. It’s really useful, and...
View ArticleCreating a caching user provider for Laravel
If you have a Laravel application that requires users to log in and you use Clockwork or Laravel DebugBar to examine the queries that take place, you’ll probably notice a query that fetches the user...
View ArticleDeploying your Laravel application with Deployer
Deployment processes have a nasty tendency to be a mish-mash of cobbled-together scripts or utilities in many web shops, with little or no consistency in practice between them. As a result, it’s all...
View ArticleWhy the speed of your MVC framework is usually a red herring
Skim through any programming-related forum and you’ll often find statements along the lines of the following: “I chose Lumen for my website because the benchmarks show it’s faster than Laravel” “I’m...
View ArticleHow I deploy Laravel apps
A while back I provided details of the web server setup I used for Django applications. Nowadays I tend to use Laravel most of the time, so I thought I’d share an example of the sort of setup I use to...
View ArticleUsing Lando as an alternative to Vagrant
Although Vagrant is very useful for ensuring consistency between development environments, it’s quite demanding on system resources. Running a virtual machine introduces quite a bit of overhead, and it...
View Article