Laravel Queue: Job Class demystified (ShouldQueue, Dispatchable, InteractsWithQueue, Queueable, SerializesModels)

Laravel is awesome, but personally I don’t appreciate their documentation as it seems always “beginner orientated”.

They trend make simple things automagically happen, without let you knowing how it works.

They you get into trouble when you need advanced functionality.

Say, you get this boilerplate when typing php artisan make:job TestJob:

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class TestJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //
    }
}

So, what actually are ShouldQueue, Dispatchable, InteractsWithQueue, Queueable, SerializesModels?
Documentation won’t tell you, even if you read the API Reference, you have little idea what they means.

Continue reading “Laravel Queue: Job Class demystified (ShouldQueue, Dispatchable, InteractsWithQueue, Queueable, SerializesModels)”

[Windows] Laravel behaving strange on Windows Server

You likely encounter those problem when developing Laravel Application using Windows Machine.

Symptoms:

  • Frequent Apache Crash (Connection reset)
  • “Access denied for user ‘homestead’@’localhost’ (using password: YES)”, even .env is set to different credential
  • .env setting drifting between two separate Laravel installations  (e.g. http://127.0.0.1:8080 .env setting applied to http://127.0.0.1:8081)

Continue reading “[Windows] Laravel behaving strange on Windows Server”

[Windows Bash] Add Rsync to “Git Bash for Windows”

In last few post we mentioned using bash in Windows by install Git.
It comes with handy *nix tools like grep, find, wget, curl, vim, ssh… but something still missing is rsync
Because it do not mean to be collection of POSIX software for Windows. It is a wont-fix for them.

Git for Windows is based on MSYS2 (As of version Git-SCM 2.13.3)
Unfortunately it does not comes with pacman (Package manager) so there are not official way to install packages.

Furthermore, cwRsync and DeltaCopy does not work in bash environment.

Continue reading “[Windows Bash] Add Rsync to “Git Bash for Windows””