General PhD path is roughly:
- 4 years undergrad
- Couple years in PhD program completing courses, maybe starting research earlier
- ??? years in PhD program chasing the paper grind, finishing with a dissertation.
So you're looking at 4 years undergrad, and anywhere between 3 (if you're really amazing) to 6,7+ years to complete the PhD. On the plus side, it can be easier to get tuition paid for you and get other comp in PhD programs (more true for some of the tech programs, but can still be true for lib ed stuff as well). So if you're ok at it, you get a stipend that covers costs, which sometimes requires you to teach undergrads or work in a lab or whatever.
Even if the PhD program itself doesn't cost you out of pocket (much if any), there's the opportunity cost because you make like less than minimum wage as a PhD student. So it is worth considering ahead of time.