Skip to content
Arie Visser

    // Category

    PHP

    These posts are about a subject that involves PHP.

    Guardrails for AI-Assisted Development in Laravel

    Guardrails have always been an important aspect of software engineering. At the beginning of my career, I was fully focused on developing new features and fixing bugs. But when a new senior joined...

    Mock Request Dependency in Laravel

    In Laravel it is seen as good practice to dependency inject the Illuminuate\Http\Request object in your methods when possible, instead of using the request() helper. One of...

    Refactoring Multiple If Statements to Objects

    In this article I would like to describe how you can refactor a method that contains multiple if-statements by creating objects with a single responsibility, each making their own assertions. Most...

    How to Split a Collection in Laravel 8

    Since Laravel 8.16, it is possible to split a collection into chunks in two different ways. The first one, that already existed, is the split method: This method breaks a collection into a...

    What is Value Object Casting in Laravel?

    Laravel 7 introduced Custom Eloquent Casts. Next to primitive types, such as json, it is also possible to cast values that form a compound to objects. This is an effective way to introduce value...

    Configuration Caching Caveats in Laravel

    With configuration caching you can bundle all configuration files, to be loaded faster by Laravel. When you run php artisan config:cache, a new file will be created in...

    A New Syntax For Foreign Keys in Laravel 7

    Since 7.x, Laravel provides a very compact syntax for creating foreign key constraints with the constrained method. In this post we will give a short demonstration of this syntax, and we...

    How to Use Stub Customization in Laravel

    Laravel 7 came with a new feature, stub customization. Stub customization gives the ability to modify the stub files that are used when creating classes such as controllers and tests with the...

    Run Tests With PHP Artisan Test

    Since the release of Laravel 7.x, you can run you tests by executing as an alternative to running your tests with the phpunit command. This command will run all your tests, until the...

    How to Use Fluent String Operations in Laravel 7

    Laravel 7 has an excellent new feature, called fluent string operations. It provides an "object-oriented interface for working with string values", e.g. becomes In this post I would like to...

    How to Ignore PHPCS Warnings

    PHP_CodeSniffer is a useful tool to check your code against a set of standards and rules. It can help in securing a certain coding standard and style within a development team, by running PHPCS as a...

    Run Elasticsearch With Laravel on MacOS

    Elasticsearch is a full-text search engine that is used by organizations such as Cisco, Adobe, eBay, Microsoft and thousands of others. With Elasticsearch you can search large amounts of documents...

    Passing Multiple Arguments To Laravel Policy Methods

    In most cases, when writing policies in Laravel, you only pass one argument to a policy method, since the authenticated user is already available through dependency injection and no other resources...

    Using The Where Clause in Validation Rules

    Just recently I discovered you can apply where statements to the unique and exists validation rules in Laravel, without using a closure. This means you can...

    Validating Array Lengths in Laravel

    One of the cool things of Laravel's validation rules, is that you can apply certain rules to different data types. When checking the minimum and maximum size of an array, you can use the...

    Sign up for the newsletter