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 >
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 >
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 >
19th April, 2022
If you are using Faker in your unit tests then you may encounter an “Unknown format” error. This means that either Faker does recognize the method that you are calling, or that Faker has not been initialized.
Read More >
4th September, 2021
After losing a few hours debugging an obscure and difficult to reproduce issue, I can say that the touch()
function in Eloquent’s database model is best avoided.
Read More >