Tag: php

How to update Laravel version with Composer

When updating Laravel to a major version, it might be straightforward but more often than not, it is not. I personally always struggle with to get it done quickly and usually spend far more time on the task, than expected. This is especially true in larger projects where there mi…

Throttle with ReCaptcha Laravel middleware

After a few days of struggling I have found a few-lines long solution to the problem of how to show ReCaptcha after a few hits on the endpoint. It is useful for for instance for payment gateway integration, where this way you make sure attacker is not abusing your app to find out…

PHP curly syntax for scope resolution is weird

When browsing a PHP documentation, an example at the bottom of the Complex (curly) syntax section explaining a usage of a scope resolution operator (::) within a curly syntax for strings in PHP caught my eye. Let's look at it: <?php // Show all errors. error_reporting(E_ALL); …

Laravel validation XOR - Exclusive OR

I needed to create a validation rule in Laravel that would accept either of the two inputs, but not both and at least one had to be supplied. In other words, I had to apply the XOR logic operation on them: ABXOR 000 011 101 110 The search results did offer many solutions but I d…

Test if a command was scheduled in Laravel 8

Testing if the command was actually scheduled might be a controversial question. Should we test if the scheduler is working and running tasks on time? Obviously no, it provided via framework and we can even see that the tests are present and integrate together. But there is a par…