Similar Posts
Laravel WebSockets as a Service
Recently Beyondcode came out with a web sockets package for Laravel. For my mailroom project I decided to add push notifications when a service receives a webhook. This a great use case for Laravel WebSockets package. In this article we will take a look at how to install it as a service using Docker and use…
Stream Filter
In php one can use filters with streams. Sometimes it can become handy. Let’s say you open a .csv file as a stream, but this file is tab separated. Your program can can process coma separated csvs, but not tab separated. This is a good use case for a stream filter, because it can make replacements…
Replace Funky Characters While Importing CSV
Sometimes uploaded text/csv file may have non-utf8 or other funky characters using the function below. public static function processUploadedBundles($request) { $content = file_get_contents($request->file(’uploadedFile’)->getRealPath()); $lines = explode(PHP_EOL, $content); $array = []; foreach ($lines as $line) { $arrayCsv = str_getcsv($line, ","); $arrayCsv = array_map(function($value){ return preg_replace(’/[\x00-\x1F\x7F-\xFF]/’, ”, $value); }, $arrayCsv); $array[] = $arrayCsv; } return…
Composer: Path Repositories
When working on a php package it is inconvenient to push the package to github (or other repository) and then wait for the package to update using composer update. For package development, composer has such feature as path repositories. Let’s imagine we have a two folders on the same level: my-app and package. my-app is an app — a test…
Debugging Webhooks
A webhook is an HTTP callback, that occurs when something happens (a resource changes its state). Webhooks provide a way to build event-driven apps, because you can be notified about changes. Since webhooks require a publicly accessible URL to function they can be hard to test from your local machine. There are three main problems…