Remove Laravel Mix during tests

Introduction

Laravel Mix is a handy Webpack wrapper for frontend asset building pipelines. It definitely helps any Laravel developer which wants to avoid the pain of Webpack setup and configuration.

For example, the following 2 lines:

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');

will apply

  • module bundling, minification, and concatenation using the app.js JavaScript file as entry point, writing the output …
Read More
Parse log files with AWK

Introduction

Not everyone can afford (or have the need of) an ELK stack for analyzing logs. Sometimes reading files from the command line is the fastest and most straightforward way to spot a problem, if you know how to filter the data.

AWK is an excellent UNIX tool (actually it’s an interpreted programming language) for processing structured data, for example rows and columns generated by applications and tools.

The word AWK comes from the initials of the language’s three …

Read More
Testing approaches for Laravel Form Requests

Introduction

Laravel Form Requests in my opinion are one of the most powerful components of the framework. They can handle request authorization and validation ahead of controllers, keeping them more clean and concise. They have been an important part of the framework since version 5.0 and dispite a few minor differences between versions, they have not really changed much.

In this post we are going to briefly introduce them, for the few of you who are not familiar with the topic, and then I …

Read More
Extract a single table from a full MySQL dump file

Introduction

At work we have to deal with very large mysqldump backups of our production MySQL databases (sometimes they can be over 10 GBs large). From time to time we have to restore single tables in our local development environment. Importing the entire database is out of question because this operation can take up to 40 minutes to complete. Manually editing the SQL dump is also impossible because opening such large files will likely kill any text editor.

I’m aware that we can use …

Read More
Test Laravel job delayed in Queue

Quick Tip

Since version 5.0, Laravel provides the possibility to delay the execution of a job later in time. You can accomplish this using the later method of the Queue facade:

<?php

$date = Carbon::now()->addMinutes(15);

Queue::later($date, new SendEmail($message));

Alternatively you may use the delay method when dispatching a job:

<?php

ProcessPodcast::dispatch($podcast)
    ->delay(Carbon::now()->addMinutes(15));

You can use a class that implements the …

Read More
Release Laravel jobs in queue without increasing attempts

Introduction

I’m currently working on a platform for processing videoclips. Our job is to extract as much information as possible (e.g. detect tags, detect faces, get dominant colors, etc.) out of each clip. Most of the heavy lifting is delegated to 3rd-party services, such as AWS Rekognition and Google Video Intelligence, which can provide the most “reliable” and cheap Machine Learning platform for this kind of tasks.

Without going too much into details, target videoclips …

Read More