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
Building a pagination component in Svelte

Introduction - What is Svelte?

Svelte is a (not so) new framework for building User Interfaces. It borrows some ideas from its more popular peers, like React and Vue.js, but it brings its own ideas into the mix, in order to maximize efficiency and performances.

Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue do the bulk of their work in the browser, Svelte shifts that work into a compile step that happens when you build your …

Read More
Require a local Composer package for development

Introduction

In PHP world Composer is currently the industry standard handling third-party packages. It allows us to automatically download the code libraries from Packagist along with all of their dependencies.

When developing a package that is going to be used in a framework, say Laravel for example, you don’t want to constantly push changes and require the package in a “real” project to test the integration. Wouldn’t be nice to include the local version of the …

Read More