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 …

Read More
Unit test Laravel pre-5.3 Queue facade

Introduction

This post is a followup of the previous one.

During my daily job I often work with old (pre 5.3) Laravel versions which do not provide fake implementations on facades, since this functionality has been introduced in version 5.3. For example with the Queue facade you can make the following assertions:

<?php

// Fake Queue functionality
Queue::fake();

// Perform order shipping...

Queue::assertPushed(ShipOrder::class, function ($job) use ($order) {
    return $job …
Read More
Unit test Laravel pre-5.3 Mail facade

Introduction

This post is only serving as a reference to how the Mail facade should be unit tested in Laravel versions previous to 5.3.


When testing an application we don’t want to send actual emails to users. We just want to fake them so we can ensure that they are getting sent, at some point, to the right users and with the right content.

Laravel provides Mail Fakes since version 5.3. This functionality allows you to easily mock the Mail facade and make various assertions …

Read More
Use import aliases in Rollup module bundler

Introduction

Sometimes, when working with JavaScript and module bundlers, it’s useful to create aliases in order to import or require some modules more easily. In Webpack for example you can use the resolve.alias directive inside the configuration file.

module.exports = {
  //...
  resolve: {
    alias: {
      'applicationRoot': path.resolve(__dirname, 'src/')
    }
  }
};

A common use case for aliases is to abstract the application root, so instead of using …

Read More
Effective pagination in AdonisJS

Introduction

Notice: I already did an introduction on AdonisJs, a Laravel-inspired web framework for NodeJS. You can read that post first if you don’t know what AdonisJS is.

In the latest months I tried to get more comfortable with AdonisJS by building a concrete side-project. My impressions so far have been really positive, even though the work required to achieve some basic functionalities is higher and less intuitive compared to the effort required in Laravel. …

Read More
How to use presenters in AdonisJs Edge templating engine

Introduction

Being a very passionate Laravel fan, I decided to step up and finally try properly AdonisJs. I already tried some small bits of it a couple of years ago, but the generator syntax did not really appeal to me. Finally with async/await we have a battle-tested MVC framework (the current version is 4.1) with modern syntax that brings Rails/Laravel concepts to NodeJs.

The value proposition of the framework is the same that fuels modern MVC frameworks: reduce the time …

Read More