Philipp Scheit

When you password contains % or other special chars in the doctrine DSN, then you need to escape them by doubling them:

{{ .Data.data.password | urlquery | replaceAll "%" "%%" }}

Full snippet to create the DSN for doctrine from several parts:

{{ with secret "secret/data/web/database" }}
DATABASE_URL="mysql://{{ .Data.data.user }}:{{ .Data.data.password | urlquery | replaceAll "%" "%%" }}@{{ .Data.data.vlanIp }}:{{ .Data.data.vlanPort }}/${var.database_name}?serverVersion=5.7"
{{ end }}

reference wich advanced filters and methods you can use in hcl2 is in the consul template docs:
https://github.com/hashicorp/consul-template/blob/main/docs/templating-language.md

--

--

Error shown when using the PropertyPath instead of the Interface

When you are using phpstan and the Symfony Component Property Access and you would get this error:

Method YAY\Sync\Subject::initPath() has parameter $path with no value type specified in iterable type Symfony\Component\PropertyAccess\PropertyPath

Make sure that you

a) have the phpstan symfony extension installed

b) you are using the interface:

private function initPath(PropertyPathInterface $path): void

instead of

private function initPath(PropertyPath $path): void

Just the plain path. The reason is, that in the phpstan symfony extension the interface is stubbed and has the iterable type applied.

--

--

Do you want to use some caching in docker-compose/docker in your CI to speedup things? You probably want to!

Given something like:

FROM php:...WORKDIR /appCOPY composer.* ./RUN composer installCOPY . ./

You have seen that before right? If your composer.lock and composer.json do not change, you have no new dependencies to install and so you definitively want to skip the composer install on every build step of your pipeline.

But this does not work like that! Somehow docker will not resolve the glob in the copy command above and cannot cache it entirely. It’ll installs everytime.

You have to change to:

COPY composer.json composer.lock ./

Struggling to make docker-caching work in your pipeline? There a tons of more tricks, should I continue? Clap for this article :) Thanks :)

--

--