Zebra Codes

How to Perform an Unbuffered Query in Laravel

26th September, 2023

If you wish to process a very large number of rows from a database then it may be prohibitively expensive to load them all into memory first. Laravel’s chunk() function may look like the solution however this performs a query for each chunk and is therefore extremely slow.

The ideal solution is to disable query buffering and thereby only ever have a single row in memory at once. Note that this option is specific to the MySQL PDO driver.

Read More >

Impersonation in Laravel 10 with Sanctum

16th August, 2023

Impersonation is a useful tool: it allows an administrator to view the website as if they were logged in as another user, but without having to know their password. The Laravel documentation implies that you can do this using Auth::loginUsingId(), but you will find that this doesn’t work.

Read More >

How to use Laravel + Vite from Docker

16th January, 2023

If you are running Laravel inside a Docker container and using Vite for Javascript/CSS bundling, you may find that the files fail to load when you view your website. You instead see one of the following errors:

  • GET http://127.0.0.1:5173/@vite/client net::ERR_CONNECTION_REFUSED
  • GET http://0.0.0.0:5173/@vite/client net::ERR_ADDRESS_INVALID
Read More >

3D Secure v2 Payments Failing Randomly

1st September, 2021

The Payment Services Directive 2 (PSD2) is a piece of EU and UK legislation that, among other things, mandates the use of a security protocol such as 3D Secure. 3D Secure until this point has been optional, but now it will be required for all online transactions. As well as now becoming mandatory, the protocol has been completely revised into version 2.

Upon adding 3D Secure v2 capability to my direct integration with Opayo (and upgrading from VPS Protocol v3 to v4, as is required), I found that certain customer transactions were being rejected by their bank, despite the majority going through successfully. No error message is given, just a failure response, and the session data threeDSSessionData field being blank.

Read More >