In most cases, yes, you have to write a book to get a doctorate. This is because a doctorate is the highest degree that can be awarded by a university, and it is expected that someone who has earned a doctorate has made a significant contribution to their field of study. This contribution is typically made in the form of a book, which presents the author's research findings and arguments in a clear and concise manner.
However, there are some exceptions to this rule. In some cases, a doctorate may be awarded without a book, if the candidate has made an equally significant contribution to their field in another way, such as through research articles, patents, or creative work. Ultimately, the decision of whether or not to require a book for a doctorate is made by the individual university or department.