Named Parameters

Currently an awesome RFC to introduce Named Parameters to PHP is in the voting phase. As I voted against this RFC and some people asked me about my reasoning I thought I share it here.

After this tweet I had some interesting conversations on and off twitter that made me think about my take on named parameters back and forth.

And as much as I like the idea of named parameters I still see one major issue in the currently proposed implementation: Changing Parameter names.

Continue reading Named Parameters

Fuck Cancer

That literally was the whole text of a tweet I send out some weeks back.

And it returned so much warmth and positive responsens for me that I want to share a bit more of the story.

Be warned: It is a sad story.

5 years ago

It all begins at the beginning of 2015 where my wife Anke was diagnosed with breast cancer. Dammit. But after all a lot happened in the last years and if it has to be cancer I’d rather have breast cancer than something else. The healing rates are rather good. So we went through this (with a lot of tears for sure) and came out stronger as a team and a family. It was sad that she couldn’t join me on my first conference gig in 2015 due to a slight overlap with her Chemotherapy but such is life.

So she won the battle. Since October 2015 everything was kind of OK. No one tells you about the fatigue that can be caused by the Chemotherapy or how slowly the body recovers after being swamped with poison multiple times for over half a year. But the main thing is: You are still alive!

Of course everything could have happened. So 5 years ago we settled everything. We went through all of it: Last will, living will, chats about how to handle the kids and all the little details that you think you will be able to handle together but that now need to be handed over. Just in case.

But everything went well. According to plan, one could say.

Well. Almost.

2020 sheds it’s light

End of last year suddenly some blood test results weren’t as they were supposed to be. That could be a sign of a new cancer but it could also be something else. So a lot of diagnosis startet again. But all results were negative. So it must be a false positive. I had a numb feeling about it but well, al the docs my wife was at couldn’t find anything and I mean they know what they are doing.

So everything was still fine.

Yes. I know what you’re thinking about! Exactly like that.

All this time Anke had issues with her back. Pain since time immemorial. But that somehow got worse. She started to walk with the dog more often but realized that herback was killing her. the amount of pain-medication shall not be revealed here, but well…. let’s put it that way. It’s good when you have sources to get prescription-only stuff. So to get to the root cause for that she made an appointment with an orthopedist. And they seemed to have found the cause for the pain. Two spinal discs that are a bit dislodged. Oh. And these shadows in your pelvis look like methastasis. Like about a dozen…

2020 finally hit

She came back that day and was completely calm. I’ve only seen her like that a handfull of times and the reason never was a good one. So I immediately canceled the call I was in at that moment and well… Imagine a lot of tears on boths sides.

At that point we didn’t know what might be the consequences. From what we heard before Methastases usually mean the end. Not necessarily right away, but that’s not something that will heal. So this is the end. The proverbial IT.

How do you handle that your whole dream of your life just shattered? She might not be able to see her kids grow. I might have to support my kids on my own in their relationships. I can’t share the joy and the tears when they marry. I will have to give them advice with their kids on my own. No getting old together. There was so much we wanted to do together.

That was barely 4 weeks ago.

But up to that time we didn’t know what it was. Three was just this MRT-Image with shadows where they didn’t belong to. So now more diagnosis. The uncertainty was perhaps the worst. No one was actually talking about metastasis as no one actually knew exactly what they were. The next day I looked for a specialist and luckily found one “nearby”. It’s interesting what you call nearby when you live in the countryside. But no matter where you want to go it’s always a 45-minute drive.

Luckily that specialist not only seems to know her stuff, the chemistry between her and Anke was just right from the start. So it looks like she is now in much better hands than the last time she fought the battle.

Finally

And now last tuesday the final results came. Anke is fighting against breast-cancer metastasis in at least her pelvis and her sternum. The therapy has started and we are talking about years that we might have togethre. Perhaps even more.

In the end we will see. There is nothing we can do other than accepting that cancer came back to stay. That the beast is now part of our live for the rest of our life.

The last weeks were hard. We talked about a lot of final szenarios. Anke started her bucket list and we might travel a tad more than we thought we would right now. We cried a lot. Death was never far away but now it is a part of our conversations . Between us two but also with our kids. And that seems to somehow take a lot of the panik.

I now have the great possibility to make the best of the time I have with the best person that I met in my life. And I don’t know how long that will be. But I know for sure that it will not be as long as we both would like it to be.

And what I learned from that tweet from the beginning is, that there are a lot of amazing people that I have the honour to call friends. That there are people in the world that are willing to support you. Sometimes people I never thought of. And that is amazing! Thank you for that!

So for now we are looking forward with the idea of still having some years together. Some tough years with pain and trauma but years we have together. So there still is some time to settle the final arrangements together. Unless one of us gets hit by a bus, that is…

Thanks for reading so far! Thanks for your support!

inspecting docker-networks

Or how not to handle a non-responsive docker container

TL;DR

Handle “Cannot start service XY: driver failed programming external connectivity on endpoint XY (ContainerID): Bind for 0.0.0.0: failed: port is already allocated” by inspecting dockers network stack and force-disconnect containers from the network.

The Problem

Today we had a non-responsive docker container that we couldn’t restart. docker-compose stop and such didn’t work. The container was still running and – especially nasty – also not responding. The website it usually provides only returned a 503 – Gateway not responding.

What to do?

Well… not what we did!
Continue reading inspecting docker-networks

Handle self-signed certificates with PHPs LDAP-Extension

Often I see questions on StackOverflow stating that connecting to LDAP-Servers secured with self-signed certificates is difficult and troublesome. Very often the accepted answer or the one with the most votes is actually the worst answer, as usually it requires to completely ignore certificates. So basically swapping the certificate would not be noticed, leaving the connection wide open for a Man-in-the-Middle attack and therefore somehow defeating the purpose of secure connections.

But how does one connect securely to an LDAP-Server secured with a self-signed certificate?

I did some tests and summarized my findings in a github-repo.

In essence it boils down to retrieving the current certificate either from the admin of the LDAP-Server or via OpenSSL using this command:

$ echo \
| openssl s_client -connect openldap:636 2> /dev/null \
| openssl x509 -text \
| sed -n -e '/BEGIN\ CERTIFICATE/,/END\ CERTIFICATE/ p' \
> /path/to/cert.pem

And then – at least when you have a supported PHP-Version – add the following lines to your ldap-code:

ldap_set_option(null, LDAP_OPT_X_TLS_CACERTDIR, '/path/to');
ldap_set_option(null, LDAP_OPT_X_TLS_CACERTFILE, '/path/to/cert.pem');

// either
$ldap = ldap_connect('ldaps://ldap.example.org:636');
// or
$ldap = ldap_connect('ldap://ldap.example.org:389');
ldap_start_tls($ldap);

Note: It’s important to call ldap_set_option before the first LDAP-Command and use null as the first argument. Otherwise it will not work 😉

You want more info? Have a look at the Repos README

what and where to .gitignore

I stumbled over a tweet of a friend of mine that sums up my feelings about what to add to a .gitignore file pretty well.

And then a debate spun up from that with the core-message that people need to know about the different ways to ignore files from automated inclusion in git-commits.

So let’s have a look at that.

git allows us to use three different ways to ignore files:

Project-specific gitignore-file

The probably best known way is by adding the filename to a file named .gitignore within the project. You can even use more than one .gitignore-File by adding one to different folders (though for obvious reasons you can only use one file per folder). Whether to use one or multiple .gitignore-files is a different discussion altogether.

This is the file the whole discussion spun around. This file should (note the conjunctive here) only be used for files that are related to your project. To give you an example imagine that you have a file .env.dist that contains a template of a .env file. Each contributor creates the .env file by copying the .env.dist and then editing it by adding credentials etc. Those credentials should never be added to the repo. So you can add the .env fiel to the projects .gitignore-file to make sure that git ignores that file. As the gitignore-file is committed it will be distributed to every contributor.

Project-specific exclude-file

Additionally you can add files to a file .git/info/exclude. That file is inside your git-folder and will therefore not be committed. So this is the best place to add files that you personally might need for your contributions but that are not relevant to everyone else. I usually have some executables in it that I created for the project but that are specific to my personal workflow. I don’t want anyone else to use them as they are hacky automation stuff but they are specific to the project.

Global gitignore-file

And finally there is a global .gitignore-file. To check where your global gitignore-file is located run this command:

git config core.excludesfile

Usually it is something like ~/.gitignore but it can be anything. Sometimes it can even be none which means that it is not configured. In that case feel free to consult your favourite search engine to find a tutorial on how to setup a global gitignore file.

This global gitignore-file is important to be able to automatically ignore all the files that are special to your personal setup but not project-specific. What files could that be, you might ask yourself now. Well: For example Apples feared .DS-Store files. Or your editors configuration files. Or your editors temporary or lock files. There are so many different possibilities. To get a general idea, you might want to have a look at gitignore.io – and the fact that there is a SAAS to generate gitignore-files shows how complicated it can be…

The great thing about this global gitignore-file is, that it applies in every git-project on your machine! So once configured it will work in every git-folder. Even in new projects that do not yet have a local .gitignore-file. And you can now safely commit code without fear that special files from your personal setup are accidentally committed.

Why all this fuss?

Well. One can of course add all the possible (and impossible?) files that certain IDEs or Editors add to your project to the project-specific .gitignore-file. But that means either having a very large file as you need to take all possibilities into account. Or it means (and that can also happen with a huge .gitignore-file) that you possibly miss something.

And imagine an editor-vendor renaming their config-setup. Or a new Editor starts to become en vogue. Now everyone needs to modify their .gitignore-files in their projects as someone might be able to commit a wrong file.

One way to make sure that no unwanted files enter a projects git-repo is to do code-reviews. Automation can help with spotting unwanted files, but it will never be able to spot all possibilities. Make sure that your code-review process spots those unwanted files.

And as a committer I will always need to be careful when committing! So before committing I should always check, that only files that I actually want to commit are committed! So I either have a look at the documentation of my Editor/IDE/Git-GUI or I use the CLI to specifically add the files. And I love git add -p – but that’s probably another blog-post.

For more infos have a look at the official documentation. And here and here are examples of project-specific .gitignore-files.