How to mock dependencies in Laravel (Full 2022 Guide for beginners)

Published January 25, 2022
How to mock dependencies in Laravel (Full 2022 Guide for beginners)

Testing your application code is absolutely a skill you should learn. It improves your own confidence so much and it keeps your application much more maintainable in the long run. Mocking is an important part of testing you code. However, it can also be a bit hard to fully grasp the concept. In this article I’ll show you all the common ways of mocking objects in Laravel.

What is mocking?

First of all,

Laravel Livewire for Beginners – Full 2021 Guide

Published December 10, 2021; last updated on January 25, 2022
Laravel Livewire for Beginners – Full 2021 Guide

If you’ve been coding with Laravel for some time, you must have heard about the ‘magical’ Laravel Livewire package. Livewire is a truly awesome (and almost magic) way to create interactive interfaces and communicate ‘realtime’ with your Laravel backend. And it does this all in a very simple way. In this article I’ll show you the basics of Laravel Livewire, so that you will be up-and-running with Livewire in no-time🚀

The combination of simplicity and power is what makes Laravel Livewire so awesome and why it is used by so many developers.

How to test Laravel notification e-mail contents

Published November 16, 2021; last updated on November 29, 2021
How to test Laravel notification e-mail contents

In this tutorial I’ll show you how to test the content of notifications in Laravel. This is particularly handy for testing whether certain data (like a confirmation number or certain credentials) is visible in the notification, similar to how you test ‘regular’ view.

For this tutorial I’ll assume you already know how to make notifications in Laravel.

How test whether a Laravel notification has been sent

First, let’s start with a simple example of testing whether a notification with subscription information was sent to a user.

Test how many times a Laravel Notification was sent

Published November 2, 2021
Test how many times a Laravel Notification was sent

Until a few months ago I barely did any automated testing on the code I wrote. That changed after I encountered the concept dubbed ‘TDD’. Sounds scary, but really isn’t. It stands for Test-Driven Development and it basically means that you write an automated test before you actually implement the feature.

The advantage of this is that you don’t need to do so much manual testing as before (you can now run a simple command to check whether the test already passes) ánd you’ve got good test coverage when you’re ready.

How to keep Laravel Horizon active with a cron job (New package)

Published October 15, 2021
How to keep Laravel Horizon active with a cron job (New package)

Laravel Horizon is a great tool for managing and monitoring your Redis queues in Laravel. It allows you to spin up queues fast and make use of all the awesome Laravel Queue features.

However, there’s one downside to Laravel Horizon. That downside is that Laravel Horizon does not restart the queues automatically if the process was terminated for some or the other reason.

Consider the scenario that you have a queue running,

Laravel Eloquent relationships for beginners – Full 2021 Guide

Published October 5, 2021
Laravel Eloquent relationships for beginners – Full 2021 Guide

Laravel Eloquent is one of the flagship features of the Laravel framework. In part that is also thanks to its awesome support for defining, creating and managing relationships between different tables of data. In this tutorial I’ll show you how to create and use Eloquent relationships, so that you can get up and running without any previous knowledge of relationships.

What are database relationships?

First, let’s start with the absolute basics. What is a relationship exactly?

How to manage DateTime with Carbon in Laravel & PHP

Published September 10, 2021; last updated on October 1, 2021
How to manage DateTime with Carbon in Laravel & PHP

At some point, almost every Laravel application needs to work with dates and times. But managing dates and times is sometimes ridiculously complex, because of timezones. In which timezone do you store dates and times? How do you calculate differences between times?

Luckily, there’s Carbon: a simple PHP API extension for DateTime. That might sound very complex, but it really isn’t. Laravel uses Carbon by default, but the documentation barely talks about it.

Laravel Eloquent for Beginners | Full guide (2021)

Published September 3, 2021; last updated on September 10, 2021
Laravel Eloquent for Beginners | Full guide (2021)

Laravel Eloquent is one of Laravel’s flagship features and one of the most notable things that distinguishes Laravel from other PHP frameworks. The Laravel Eloquent ORM is a way to interact with your database. In this tutorial I’ll show you the basics of using Laravel Eloquent, so that you can start using Eloquent quickly.

So, what is Eloquent exactly? Or what is an Eloquent model? It effectively comes down to the following: for each table you have in your database,

Laravel Databases & Migrations for Beginners (2021)

Published August 20, 2021; last updated on September 10, 2021
Laravel Databases & Migrations for Beginners (2021)

Laravel provides a whole bunch of tools to interact with your application’s database. The most important one is Eloquent, which is one of Laravel’s most popular and influential features. In a world of powerful, but complex tools, Eloquent stands out for its simplicity. But before we dive into Eloquent, it’s a good idea to first get everything set up and understanding the basics of Laravel’s database functionality: connections & migrations.

In this tutorial,

How to use Browsersync with Laravel Valet (2021)

Published August 3, 2021; last updated on September 10, 2021
How to use Browsersync with Laravel Valet (2021)

If you’re a developer in the PHP world, it’s likely that you’ve come across Laravel Valet. Laravel Valet is a very easy way to spin up multiple local development environments, by linking a folder name to a {folderName}.test domain.

Browsersync is a tool to make developing easier. It offers handy tools, of which the most important is automatic browser reloading on file change. Unfortunately Browsersync doesn’t work out-of-the-box with Laravel Valet, but luckily it requires only a little configuration.

Close
Stay up to date with all things Laravel, Tailwind, WordPress & PHP

Subscribe now to my e-mail newsletter and get my latest articles and project updates delivered directly to your inbox. Never miss an update.