[Docker] PHP LibXL integration on Docker Image (Ubuntu 18.04)

Compile LibXL extension for PHP 7.2 @ Ubuntu 18.04, using Docker multi-stage build

Dockerfile

FROM ubuntu:18.04 as build

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y php7.2-dev libxml2-dev git wget

RUN wget http://www.libxl.com/download/libxl-lin-3.8.5.tar.gz && \
tar -zxv -f libxl-lin-3.8.5.tar.gz && \
cd libxl-3.8.5.0/ && \
cp lib64/libxl.so /usr/lib/libxl.so && \
mkdir -p /usr/include/libxl_c/ && \
cp include_c/* /usr/include/libxl_c/

RUN git clone https://github.com/Jan-E/php_excel.git -b php7-issue241 && \
cd php_excel && \
phpize && \
./configure --with-php-config=/usr/bin/php-config --with-libxl-incdir=/usr/include/libxl_c/ --with-libxml-dir=/usr/include/libxml2/ --with-excel && \
make

FROM ubuntu:18.04

# Install your PHP stack 
[...]

# Install LibXL
COPY --from=build /php_excel/modules/excel.so /usr/lib/php/20170718/

COPY --from=build /libxl-3.8.5.0/lib64/libxl.so /usr/lib/libxl.so

COPY ./docker/excel.ini /etc/php/7.2/mods-available/

RUN phpenmod excel

# Other stuff
[...]

/docker/excel.ini

; priority=30
extension=excel.so

[excel]
excel.license_name="Tiger Fok"
excel.license_key="linux-xxxxxxxxxxxxxxxxxxxxxxxxxxx"
excel.skip_empty=0

Laravel Job: Common problem – Queue stuck, not responding to “artisan queue:restart”

Laravel queue is quite easy to setup and use.

But how it actually work is seem like a mystery and undocumented

There are some pitfall that beginner usually fall into, the common one is stucking

Continue reading “Laravel Job: Common problem – Queue stuck, not responding to “artisan queue:restart””

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)”