All posts by Andreas Heigl

About Andreas Heigl

father, husband, developer, architectural daughtsman, brother, master of forestry sciences, scout, rescue diver

Do not be alarmed – Or do!

This morning I watched a video on Rusts Error-Handling that Larry Garfield posted on Mastodon.

The essence – at least to me – is that Exceptions throw one out of the normal flow of execution just like GOTO does. And we all know that GOTO is bad. SO how does Rust handle Errors, when Exceptions are bad and we always want to return a defined type?

Rust uses Result “enums” instead of a dedicated type that a function returns instead of throwing an exception or returning null. They contain either the expected return value or an Error.

I am not a mathematician. So I might be getting things wrong from a logical point of view. But as a developer I do have a slightly different view on the topic of Error and Exception handling.

Continue reading Do not be alarmed – Or do!

Hair

With the start of this year my better half changed cancer treatment. Or should I say “we changed treatment”? After all, she is the one taking the shot, she is the one fighting her body, she is the one dealing with the fatigue, she is the one affected by the treatments sideeffects.

And we as a family do our best to support her. Comfort her. Challenge her. Bear seeing her struggle without any means of help. But that’s perhaps for another day.

Why did she change treatment? Well. When your oncologist tells you that the metastasis in the liver need a tad more attention, you provide them attention.

Continue reading Hair

Debug LDAP via TLS

Yesterday I had to do some debugging to find out why an LDAPS connection didn’t work.

The main trouble was that the authLdap plugin for WordPress didn’t work for someone. After a bit of back and forth we figured out that it worked for other applications but not for PHPs LDAP-extension.

The error they got was the usual cryptic Can't contact LDAP server which says nothing at all as that can mean so many different things.

Continue reading Debug LDAP via TLS

Email notification for SSH logins

On servers I maintain I usually have a script running that sends an email whenever someone logs in via SSH. It allows me to keep track on whether something fishy is going on in a very easy way.

It’s not bulletproof but at least provides me with a certain level of safety that everything is all right.

The other day I had to reinstall a server after some time and of course I had to – again – search for how to set that email script up.

Continue reading Email notification for SSH logins

Xdebug in Docker

Yesterday Dmitri Goosens wrote about how to integrate Xdebug into almost any Docker Setup in PHPStorm. An article that I definitely need to digest a bit more as the PHPStorm integration is something that I often neglect. I am happy when it works on the CLI šŸ˜

One thing though that Dmitri skips though (an dfor good reasons) is how to get Xdebug into your Docker environment.

As I have done that quite a number of times by now I thought I’d share the way I do it currently.

This is my Dockerfile

FROM php:8.3-rc-fpm
RUN PHPIZE_DEPS="autoconf \
      cmake \
      file \
      g++ \
      gcc \
      libc-dev \
      libpcre2-dev \
      make \
      git \
      pkgconf \
      re2c" \
    && XDEBUG_VERSION="" \
    && if [ "$(php -v | head -n 1 | grep 8.3)" != "" ]; then XDEBUG_VERSION="-3.3.0alpha3"; fi \
    && apt-get update \
    && apt-get install -y $PHPIZE_DEPS \
    && pecl install xdebug${XDEBUG_VERSION} \
    && docker-php-ext-enable xdebug \
    && echo "xdebug.mode=debug\nxdebug.discover_client_host=on\nxdebug.start_with_request=yes\nxdebug.log_level=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && apt-get remove -y $PHPIZE_DEPS

That should install a running version of Xdebug on whatever version of PHP you are using and even allows to use the soon to be relesased PHP8.3.

The main lines here are

    pecl install xdebug${XDEBUG_VERSION} \
    docker-php-ext-enable xdebug \

everything else is decoration resp. necessary that those two lines can do their magic.

Feel free to adapt the FROM line to whatever PHP-version you want to use from dockers official PHP-image (remember that that is not maintained by the PHP folks! It’s maintained by Docker!)

After a docker build -t phpxdebugtest . you should now be able to call docker run phpxdebugtest php -v and see this

PHP 8.3.0RC5 (cli) (built: Nov 1 2023 05:26:54) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0RC5, Copyright (c) Zend Technologies
with Xdebug v3.3.0alpha3, Copyright (c) 2002-2023, by Derick Rethans

And now have fun integrating that Xdebug enabled PHP-Container into your PHPStorm.