Thank you kind historian.:)
The modern research PhD dates to the early 19th century, when the modern research was developed in Prussia. (There are still non-research PhDs today; while many universities give their coursework-only doctorates other names, some call them PhDs.)
However, the PhD existed as a Medieval degree, and before then, "Doctor PhilosophiƦ" existed as a job title ("philosophy teacher").
For the long version and references, see my past answer in https://www.reddit.com/r/AskHistorians/comments/dv4ppq/when_was_the_first_phd_awarded_and_what_led_to/