Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Wisk-php project

We have PHP project as a seed in module-laravel
It uses Laravel 9.2

History:

  • Wisk was initially developed in PHP Laravel.
  • Then we moved the business logic to Swift and Kotlin
  • The only part that remains, that we kept because it’s solid, it’s the PDF generation
    • Specifically the library mPDF, that transforms HTML to PDF, is very good so we kept it.
  • Later we added a custom XLS generation
    • Maatwebsite Excel is a very good library for that
  • We also use Horizon for queue management, this is put in a separate repository, see below

Currently, Wisk uses PHP Laravel for a few very specific tasks:

  • generate PDFs using the mPDF library
  • generate XLS files
    • Quick note: the main inventory/consumption XLS are generated in Kotlin https://github.com/WiskSolutions/wisk-xls

The repository is https://github.com/WiskSolutions/wisk-php

Code structure

  • The project is build in PHP Laravel
  • You can find the supported routes in routes/web.php img_8.png

Examples

Inventory download

Route::post('/inventory/{id?}/pdf', ['uses' => 'App\Http\Controllers\PDFDownloadController@download_inventory_pdf']);

In PDFDownloadController you can find the code for generating the PDF

   public function download_inventory_pdf(Request $request, $inventory_id)

In PDFReportProcessor

    public function generate_inventory_pdf_data($inventory_id, $venue_id, $location_id = null)

This code will call the resources/views/print.blade.php template and will generate the html for the PDF

    $html = view('print', $data)->render();

How to run the project locally

Install PHP

brew install php
composer update
php artisan serve --port=8888
Starting Laravel development server: http://127.0.0.1:8888

In order to call an API that’s deployed locally you need to change the wisk-php .env file to point to the local API

API_HOST=http://127.0.0.1:8000

example: img_27.png

Note: if order for the wisk-api to communicate with the local wisk-php instance you have to change the WISK_PHP schema variable (please see more details in the swift setup document)
Example (for wisk-api running locally): WISK_PHP=http://127.0.0.1:8888

By default PHP will communicate with the WISK Dev API to fetch the data

class API
{
    public static function fullPath($path) {
        $url = env('API_HOST', 'https://api.wisk.dev');

In Postman we have a collection for testing the PHP project img_9.png

XLS download

The structure is very similar to the PDF download It uses the PHP library called Maatwebsite https://github.com/SpartnerNL/Laravel-Excel

Route::post('/inventory/locations/spreadsheet', ['uses' => 'App\Http\Controllers\XLSDownloadController@download_inventory_by_location_xls']);

Wisk Queue Horizon wisk-queue-horizon

This project is also built using PHP Laravel with Horizon
Horizon provides a beautiful dashboard and code to manage the queue img_28.png

See the README.md from the project for more details, it will help you to run the project locally