Category Archives: PHP

Transliter… what?

Every now and then I am challenged with modifying Unicode-strings. Whether by converting from any non-ASCII script to ASCII or handling differently normalized strings, all of these actions are called “Transliteration”

I first encountered that when I built an application that create PDF-Files on a Linux-Server that would then be overwritten from an application running on a mac that had the folder mounted via CIFS. Everything was working great. Until one of the people thought it would be a great idea to enter a filename with a german Umlaut. So the application created the file “example_ä.pdf” on the server. After some time we realized that there was a second file in that folder with the name “example_ä.pdf”.

Wait!

What?

Continue reading Transliter… what?

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

Scoping PHAR-files

PHAR-files are a great way to bundle code that can then be used like a binary. Therefore PHAR-files are often used for tools that can be included in a CI/CD setup. As they are self-contained archives they use their own autoloading mechanism and therefore don’t depend on your code. Which is great if you want to use them as build-tools because the tools dependencies don’t interfere with your project dependencies.

Imagine you’d want to use a build tool that requires PHP 7.2 with your legacy code that still needs to run with PHP 5.6… Most probably your composer require --dev awesome/build-tool would not work because of a dependency mismatch. Even though you might be on PHP 7.2 at the moment. Using the PHAR-file removes that dependency as all the required files are contained within the archive. And the PHARs autoloader takes care of getting the right files.

Continue reading Scoping PHAR-files