Does every PhD student have to officially enrol at the university?

Some, but not all, PhD students are enrolled at their university. Whether it is a good idea to matriculate depends on your individual life situation. PhD studies may be relevant with regard to insurance or state benefits. It is worth mentioning that in Germany, the maximum duration of a PhD programme may differ, depending on the federal state (Bundesland). In Bavaria, for example, matriculation is limited to just six semesters, with a few precisely regulated exceptions. However, this does not mean that the thesis has to be completed within this period of time and that the PhD procedure will be regarded as failed upon becoming unenrolled. In other words, the PhD status is independent of the matriculation status.