bookmark_borderPHP 8 Named Arguments

In PHP 8, you can use named arguments, which allows you to provide the parameters of a function in any order:

PHP 7.x

// haystack must come first
$pos = strpos('Hello World', 'World');


// I can tell it what each param is, so the order is up to me
$pos = strpos(needle: 'World', haystack: 'Hello World');

Even if you choose not to reorder the params, it will make the code clearer and easier to read.

bookmark_borderA fast way to reformat code in PHPStorm

Today I found a way to do a regex find that makes reformatting code easy.

Let’s say we have some code like this:


and you want it formatted like this:

<p>{{ $variable }}</p>

This is what I prefer because it gives more breathing room and makes the code easier to read. But these can be scattered in many places in your code.

By doing a global find/replace using this regex, you can replace them all in one shot:

\{\{(?! )

It uses a negative lookahead, which means it will find all occurrences of {{ that are not followed by a space. You could find the closing portion by reversing it. Then use the global replace function and make your commit.

Get in, get it done, move on to the next task!


Have you heard of the pipeline pattern? The pipeline pattern is used by Laravel internally, and is a really nice way to clean up your code.

I found a video that explains it well. I watched yesterday, then today I did a code-along and built it myself to reinforce the concepts. If you havenโ€™t used this pattern before, definitely check out the video and learn something new today! ๐Ÿ˜Š