Author: Mathias Lipowski

PHP: get version details from composer.json

Let’s say we have a composer.json file as follows:

    "name": "mixable/blog",
    "description": "",
    "homepage": "",
    "version": "4.0.1",
    "type": "project",
    "require": {
        "php": "^8.x",
        "vendor/package": "^4.3",

When using this file to manage the packages of an app, it might be necessary to check for the version of your app. This is possible by using the Composer class \Composer\InstalledVersions. The class provides different methods to access the details of the projects composer.json file.

Get details about the root package

Details about the root package are available through the getRootPackage() method:

$package = \Composer\InstalledVersions::getRootPackage();

This method returns an array with the following details:

name: string
version: string
reference: string
pretty_version: string
aliases: string[]
dev: bool
install_path: string
type: string

To get the apps version, you can use:

$version = \Composer\InstalledVersions::getRootPackage()['version'];

Get details about installed packages

There is a number of methods that provide additional information about the installed packages. Some examples:

Version of an installed package

$version = \Composer\InstalledVersions::getVersion('vendor/package');

Install path of an installed package

$installPath = \Composer\InstalledVersions::getInstallPath('vendor/package');

A detailed description of all methods is available at

Photo by Ilya Pavlov on Unsplash

GitLab CI + Flutter: pub: command not found

In one of my projects, I used a GitLab environment to perform Flutter tests. For this, I setup my .gitlab-ci.yaml to use a Flutter docker image of cirrusci/flutter for code quality check or tests. The file looks like this:

  stage: test
  image: "cirrusci/flutter:stable"
    - docker
    - pub global activate dart_code_metrics
    - export PATH="$PATH":"$HOME/.pub-cache/bin"
    - metrics lib -r codeclimate  > gl-code-quality-report.json
# [...]

  stage: test
  image: "cirrusci/flutter:stable"
    - docker
    - pub global activate junitreport
    - export PATH="$PATH":"$HOME/.pub-cache/bin"
    - flutter test --machine --coverage | tojunit -o report.xml
    - lcov --summary coverage/
    - genhtml coverage/ --output=coverage

# [...]

Up to version 2.10.* of the Flutter docker image, this worked fine. But starting with version 3.0.0, there seems to be some changes in the binaries or their paths. The scripts failed with an error:

/usr/bin/bash: line 123: pub: command not found

To fix this error, the pub commands need to be adjusted and set to flutter pub:

# [...]

    - flutter pub global activate dart_code_metrics

# [...]

    - flutter pub global activate junitreport

# [...]

This fixed the issue and all tests finished successfully.

MySQL error: Cannot truncate a table referenced in a foreign key constraint

By default, you cannot TRUNCATE a table that has foreign key constraints applied on it. This is to keep the data consistent over multiple tables that are linked by constraints.

Solution 1

The fastest way to clean the table is to disable FOREIGN_KEY_CHECKS:

TRUNCATE `table1`;
TRUNCATE `table2`;

Keep in mind, that disabling FOREIGN_KEY_CHECKS might result in inconsistent data with foreign key values that do not exists.

Solution 2

To remove all rows, you can also go the long way:

  • Remove all foreign key constraints
  • Run TRUNCATE on the table(s)
  • Manually delete all rows without reference
  • Recreate the foreign key constraints

Photo by Jan Antonin Kolar on Unsplash

Markdown: how do I add a newline in a table?

When creating tables in markdown, you use the vertical line | to split the columns. Each line of the document represents a row of the table. So adding a normal line break will result in a new row by default. Let’s assume you have a table with a large text and you want to split this text only in a single cell to improve readability. When using this markdown:

| Date | Action | Query |
| ---- | ------ | ----- |
| 2022-04-28 | none | search |
| 2022-04-25 | /url/to/my/page, added details about this topic, improved description | new |

This will create the following output:

To add a line break inside a table cell, you can simply use a html line break <br> . This is also suggested for line breaks in simple text outside tables. So the same contents with a line break:

| Date | Action | Query |
| ---- | ------ | ----- |
| 2022-04-28 | none | search |
| 2022-04-25 | /url/to/my/page<br> added details about this topic, improved description | new |

Will result in the following output:

And there you have it: a table with a line break inside a cell.

Die neueste mixable-App ist da – finde Deine Drinks noch einfacher!

Mit dem neuesten Update steht eine komplett überarbeitete Version der mixable App zur Verfügung. Die neue Version besitzt zahlreiche Verbesserungen und neue Funktionen, mit denen sich Cocktailrezepte noch einfacher finden lassen. Hier die wichtigsten Funktionen:

Einzigartige Suchfunktionen

Mit der einzigartigen ‘Was trinken?’ Funktion schlägt Dir die App Rezepte vor, welche perfekt zu Deinem Geschmack passen. Egal ob Dir gerade nach einem fruchtigen, sahnigen oder herben Cocktail ist, anhand kurzer Fragen wird eine Liste an passenden Cocktailrezepten erstellt. Standardmäßig werden dabei alle Rezepte von durchsucht. Du kannst ‘Was trinken?’ jedoch auch auf Deinen Barbestand oder eine andere Rezeptliste oder Kategorie anwenden.

Zahlreiche Filter

Die Stichwortsuche bietet eine Vielzahl an Suchfiltern zum Verfeinern der Suchergbenisse. Somit lassen sich Rezepte in speziellen Kategorien, mit bestimmten Basisspirituosen oder anderen Eigenschaften sehr einfach finden.

Rezepte in Sammlungen verwalten

Verwalte und sortiere die Rezepte in eigenen Sammlungen. Damit lassen sich Deine Favoriten nach unterschiedlichen Kriterien ordnen.

Barbestand verwalten

Möchtest Du wissen, was sich mit Deinem Barbestand mixen lässt? Dann hilft die ‚Meine Bar’ Suchfunktion weiter. Wähle die Zutaten Deiner Bar und ‘shake it’ um zu sehen, was damit mixbar ist.

Darüber hinaus lassen sich all Deine Daten mit einem Konto über verschiedene Geräte hinweg synchronisieren.

Why does the iOS App Store show more languages than my app supports?

By default, the languages of an app are listed in info.plist by setting the values for the properties list key CFBundleLocalizations. A definition as shown below should result in supported languages English and German.


But when looking at the AppStore, the languages shown there do not always correlated with this setting. The reason is that the languages shown on the AppStore are generated automatically based on the localized *.lproj folders found in your app.

Normally those folders should be in sync with your properties list setting. But when you use third party libraries (e.g. with CocoaPods) additional localizations might be loaded into your app. In this case, all *.lproj folders found in your app and in the pods are used for language determination.

How to correct the languages?

There is a plugin for that: cocoapods-prune-localizations, which can be simply added to your Podfile. When running pod install, this script will remove all localized files from pods or just keep the specified languages. To install the script, run:

gem install cocoapods-prune-localizations

Then add the following lines to your Podfile:

plugin 'cocoapods-prune-localizations'

Localizations will be inferred from your project.

or if you would prefer to specify the localizations:

plugin 'cocoapods-prune-localizations', {:localizations => ["en", "es"]}

This will keep the English and Spanish localizations in the Pods. Modify the localizations to your needs.

Photo by Etienne Girardet on Unsplash

Build and Release a Flutter App

Updating the app’s version number

To update the version number, navigate to the pubspec.yaml file and update the following line with the current version string:

version: 1.0.0+1

After the change, run:

flutter pub get

Build and release the iOS app

A detailled description of the whole process is described at

To release the iOS app, you use Flutter to build a xcarchive file. This build archive can be published the same way you would do it with Xcode by using the archive manager and one of the different Distribution options.

Build the iOS app:

flutter build ipa

The generated xcarchive file is saved to your app directory under:


Build and release the Android app

A detailled description of the whole process is described at

To release the Android app, you use Flutter to build a app bundle aab file. This file can be distributed by using Google Play Console or any other store.

Build the Android app:

flutter build appbundle

The generated aab app bundle file is saved to your app directory under:


Photo by Artur Shamsutdinov on Unsplash

Ping server on a specific port


You can’t ping ports, as Ping is using ICMP which doesn’t have the concept of ports. Ports belong to the transport layer protocols like TCP and UDP. However, you could use nmap to see whether ports are open or not:

nmap -p 80

The output will look like this:

nmap -p 80
Starting Nmap 7.92 ( ) at 2021-12-08 10:59 CET
Nmap scan report for (
Host is up (0.017s latency).
rDNS record for

80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds